views:

38

answers:

1

To fill one variable with a value from a query I can write following:

SET @TargetID = (SELECT TOP 1 ID FROM @bigDataSet ORDER BY date DESC)

To fill multiple variables from this query, eg. something like:

SET (@TargetID, @TargetName) = ....(SELECT TOP 1 ID, [Name] FROM @bigDataSet ORDER BY date DESC)

what can I write?

+5  A: 
SELECT TOP (1) @TargetID=ID, @TargetName=Name 
FROM @bigDataSet 
ORDER BY date DESC
Martin Smith
thanks for the quick answer.
littlegreen