Skip to main content

AddToAny

Share/Save

Set two variables using a Select query in a stored procedure.

1 reply [Last post]
shantanu
shantanu's picture
User offline. Last seen 29 weeks 6 days ago. Offline
Joined: 08/20/2009
SET @Password = ( 
    SELECT Value1,Value2
    FROM [dbo].[Table1]  
    WHERE [Expr1]) 

I am trying to get both values 'Value1' and 'Value2' in two variables to be used in same SP in next query. Is it possible or do I have to write two queries for this. Is it there a concept of arrays in sql server

Anonymous
Anonymous's picture
Use TSql variables in the

Use TSql variables in the select query. i.e As in your case

DECLARE @Value1 INT
DECLARE @Value2 INT
 
SELECT
       @Value1=Value1,
       @Value2=Value2,
 FROM  [dbo].[Table1]
 WHERE [Expr1]