I really just need to know if this is possible without writing two queries to fill the variables.
I want to map the index of the fields in the query to the user variables.
Here is what I need to do :
DECLARE @a varchar(20);
DECLARE @b varchar(20);
SET @a(0)@b(1) = (
SELECT TOP 1
a
,b
FROM
c)
If @a = 'val1' and @b = 'xval2' Then
Begin
Select 'test'
End
Obviously above won’t work.
Try to set the @ variables within the query:
SELECT @a=a, @b=b FROM c...Here is another example:
This prints a login and a department group from a table called login and assigns them to the variables a and b respectively.
In your case: