简体   繁体   中英

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!

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM