I have a stored procedure with a query that selects multiple values, each of which I would like to assign to local variables. I am aware of how to set a single local variable by way of SET @variable1 = SELECT * FROM TABLE WHERE Column = 'unique value', but as I said, this only works for single variables.
My initial thoughts were if it were possible to do something such as:
DECLARE @variable1, @variable2
SELECT column1, column2
FROM table1
WHERE column1 = 'unique value'
SET @variable1 = column1
SET @variable2 = column2
Obviously this does not work, but I am hoping that there is a method to accomplish something like this.
My initial thoughts were if it were possible to do something such as:
DECLARE @variable1, @variable2
SELECT column1, column2
FROM table1
WHERE column1 = 'unique value'
SET @variable1 = column1
SET @variable2 = column2
Obviously this does not work, but I am hoping that there is a method to accomplish something like this.
Comment