当前位置: 代码迷 >> ASP.NET >> 看看这句存储过程错在哪.解决思路
  详细解决方案

看看这句存储过程错在哪.解决思路

热度:4864   发布时间:2013-02-25 00:00:00.0
看看这句存储过程错在哪...
是语法错误,应该怎么改?

insert     into     Article   (father_id,   author_id,   title,   text)  
values
(@father_id,   select     id       from     userinfo     where     username=@username,   @title,   @text)


谢谢~


------解决方案--------------------------------------------------------
declare @authorID int

select @authorID = id from userinfo where username=@username

insert into Article (father_id, author_id, title, text)
values
(@father_id, @authorID, @title, @text)
------解决方案--------------------------------------------------------
insert into Article (father_id, author_id, title, text)
values
(@father_id, select id from userinfo where username=@username, @title, @text)

SQL语法错误,不能这样用
可改为

insert into Article select @father_id, id , @title, @text from userinfo where username=@username
  相关解决方案