Skip to content
Advertisement

Store a list of numbers returned by a query into a variable

I’d like to store the Ids returned by a query like so into a variable:

So that I may later say something like:

How do I do that? Specifically, what datatype must I declare such a list variable to be of?

Notice that I could have simply done:

But I don’t can’t do that for reasons that will simply complicate the question.

I am using Microsoft SQL Server 2014.

Advertisement

Answer

use temp table or table variable to store the Id

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement