tags:

views:

33

answers:

3

I have something like this

declare @foo bigint;
declare @bar nvarchar(20);

set @foo = select foo from theTable where id = 37;
set @bar = select bar from theTable whre id = 37;

is it possible to do this with a single select ?

+4  A: 
SELECT  @foo = foo,
        @bar = bar
FROM    theTable
WHERE   id = 37
David M
+2  A: 

Yes, you can do this in a single sql query using:

SELECT @bar = bar, @foo = foo from theTable whre id = 37;
OMG Ponies
+3  A: 

This is not possible if you use the SET command .. but if you use SELECT, you can do it.

SELECT @foo = foo, @bar = bar FROM theTable where id = 37
BryanD