Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 246
user1429210 Avatar asked Apr 23 '14 15:04

user1429210


1 Answers

You can do it via SELECT:

SELECT @a = 0, @b = 0

With SET you need 2 SET commands:

SET @a = 0; SET @b = 0
like image 97
Yuriy Galanter Avatar answered Nov 01 '22 14:11

Yuriy Galanter