问一段存储过程

笨马克 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 行: ')' 附近有语法错误。

请问错在什么地方?应该怎么改?
谢谢
...全文
50 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

34,594

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧