how to store output of query into variable in sql server code example Example: how to store the query result in a variable sql SET @anyVariableName = ( yourQuery);