读书人

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

发布时间: 2012-02-21 16:26:23 作者: rapoo

看看这句存储过程错在哪...
是语法错误,应该怎么改?

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

读书人网 >asp.net

热点推荐