Due to runtime I want to asign the columns of a single-row-resultset to multiple variables at once in a SQL-Server stored Procedure. I want to replace the last 2 lines of the following code:
Declare @A int
Declare @B int
Select @A = (Select Col1 From Table1 Where ID=1234)
Select @B = (Select Col2 From Table1 Where ID=1234)
Since in this version the program would search twice for the ID=1234 i want to do something like
Select @A, @B = (Select Col1, Col2 From Table1 Where ID=1234)
But i can't figure out the correct syntax for this.