What is the best way to accomplish the equivalent of executing scalar in T-SQL? In other words, using SQL, how can I get the first column of the first row of the first result set when calling a stored procedure?
Edit:
Just for clarification, this is only using SQL, not a client-side language. The result set could be something like this:
Id Description
--------------
1 foo
2 bar
I need only "1" in the variable.
The only way I know how to do this is to create a temporary table (untested, but you get this idea):
INSERT
DECLARE @id INT;
SELECT TOP(1) @id = Id FROM
source
share