Question

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?

Was it helpful?

Solution

You can do it via SELECT:

SELECT @a = 0, @b = 0

With SET you need 2 SET commands:

SET @a = 0; SET @b = 0

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top