How to set two local variables with the same value in sql server?

This question should be really stupid, but I have not found an answer yet.

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

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

How to do this using SET ?

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

+4
source share
3 answers

You can do this via SELECT:

SELECT @a = 0, @b = 0

SET SET:

SET @a = 0; SET @b = 0
+2

1

set @a = 0 
set @b = 0

2

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

Set @a=0 
Set @b= @a

set @a = 0 
set @b= 0
0
source

Source: https://habr.com/ru/post/1537738/


All Articles