存储过程,如何选择多个变量?

时间:2011-03-01 16:06:31

标签: sql stored-procedures

My Stored Proc的表现并不像我期望的那样。我期望从1个select语句中填充多个变量。

像这样:

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

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

但是,此选择后变量始终为空白。我确信结果集是标量,数据实际存在。

明显的错误在哪里,谢谢!

1 个答案:

答案 0 :(得分:7)

这应该有效,我想(我相信有人会纠正我!)。

你绝对确定数据是否存在?

如果添加

print @Phone
print @Fax

之后,他们都是空白的?

相关问题