This question must be really silly, but I haven't found an answer for it yet.

I'm making a program in C # that dynamically writes a script to run on SQL Server. I declared two variables that receive the values returned from two calls exec 'procedure_name'.

In the next block of the script, I want these variables to be set to zero.

How to do this using a SET?

would be something like this: SET @ a, @ b = 0?

有帮助吗?

解决方案

You can do it via SELECT:

SELECT @a = 0, @b = 0

With SET you need 2 SET commands:

SET @a = 0; SET @b = 0

其他提示

Method 1

set @a = 0 
set @b = 0

Method 2

Select @a = 0, @b = 0
Select @a = 0
select @b = 0

OR

Set @a=0 
Set @b= @a

Or

set @a = 0 
set @b= 0
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top