15

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?

1 Answer 1

22
SELECT TOP (1) @TargetID=ID, @TargetName=Name 
FROM @bigDataSet 
ORDER BY date DESC
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.