开发者

Stored Proc, how to select into multiple variables?

开发者 https://www.devze.com 2023-02-13 23:44 出处:网络
My Stored Proc is not behaving how I would expect. I am expecting to populate multiple variables from 1 select statement.

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 开发者_StackOverflow中文版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?

0

精彩评论

暂无评论...
验证码 换一张
取 消