问一段存储过程
笨马克 2004-03-05 09:18:23 从表中获取这样得记录:replyID=0 and userID=u.userID and close_up=0 并且三个字段scopes、type和product中的int型数据要包含在字符串@expert_attribute(传过来的参数,是一串类似"78,20,3,56,"的字符串)中。
我写的是这样的:
CREATE PROCEDURE receivequestion
(
@userID int=0,
@expert_attribute varchar(2000)=''
)
AS
Begin
create table #temp(questionid int,userid int,username varchar(20),title varchar(50),feedbacks int,addtime char(10))
if (select usertype from user_base where userID=@userID)=2
Execute('insert into #temp(questionID,userid,username,title,addtime) select v.questionID,v.userid,u.username,v.title,convert(char(10),v.addtime,120) from vipquestion v,user_base u where v.replyID=0 and v.userID=u.userID and v.close_up=0 and v.scopes in ('+@expert_attribute+') and v.product in ('+@expert_attribute+') and v.type in ('+@expert_attribute+')')
update #temp set feedbacks=v.feedbacks from #temp r,(select replyID,feedbacks=count(replyID) from vipquestion where replyID in (select questionID from #temp) group by replyID ) v where r.questionID=v.replyID
End
select * from #temp order by questionid desc
GO
报错是:
服务器: 消息 170,级别 15,状态 1,行 1
第 1 行: ')' 附近有语法错误。
请问错在什么地方?应该怎么改?
谢谢