charles.frank
SSC-Addicted
Points: 497
More actions
November 6, 2008 at 2:02 pm
#195667
Hi All,
I'm trying to store the result of a query in a parameter and haven't figured out how to do it. This is giving me errors:
DECLARE @a INT
SET @a = SELECT MAX(MasterID) FROM Table
The result of the query will always be one unique number. Does anybody know how this is done?
Thanks
November 6, 2008 at 2:12 pm
#895226
Got it....was missing parentheses.
This works
SET @a = (SELECT MAX(MasterID) FROM table)
David Webb-CDS
SSCoach
Points: 17398
November 6, 2008 at 3:06 pm
#895247
This form will let you set more than 1 variable
select @variable1 = column1, @variable2 = column2 from ...
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply