I want to do this:
Declare @a int;
Declare @b int;
SET @a,@b = (SELECT StartNum,EndNum FROM Users Where UserId = '1223')
PRINT @a
PRINT @b
But this is invalid syntax. How do I set multiple scalar variables in one select statement? I can do:
Declare @a int;
Declare @b int;
SET @a = (SELECT StartNum FROM Users Where UserId = '1223')
SET @b = (SELECT EndNum FROM Users Where UserId = '1223')
PRINT @a
PRINT @b
But this will take twice as long. What is the fastest way?
1 Answer