开发者

SQL server-declare local variable: "there is already an object named '' in the database"

I wrote the following stored procedure, in which I use a local variable 'syncParam':

declare @syncParam bit

select isSync into syncParam from MyTable where id=@id
if (@syncParam='True')..开发者_开发问答.
else ...  

return @syncParam

When I executed this stored procedure at the first time it worked, but after that I get the following error: "there is already an object named 'syncParam' in the database".

What did I miss?

Thanks in advance.


You want

select @syncParam  = isSync from MyTable where id=@id

SELECT INTO will insert records into a new table. Go look, you should have a syncParam table now.


you might consider using a temp table .. just rename the table #syncParam

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜