JL.
JL.

Reputation: 81262

Stored Proc, how to select into multiple variables?

My Stored Proc is not behaving how I would expect. I am expecting to populate multiple variables from 1 select statement.

Like this:

Declare @Phone nvarchar(30); 
Declare @Fax nvarchar(30); 

select @Phone = phone , @Fax = fax from customer where customerID = 1;

However, the variables are always blank after this select. I am sure the result set is scalar, and data actually exists.

Where is the obvious blunder, and thanks!

Upvotes: 2

Views: 3381

Answers (1)

Tom Morgan
Tom Morgan

Reputation: 2365

That should work, I think (I'm sure someone will correct me!).

You're absolutly sure the data exists?

and if you add a

print @Phone
print @Fax

immediatly after, they're both blank?

Upvotes: 7

Related Questions