2

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!

2
  • Are you sure that select * from customer where customerID = 1 returns any values? Commented Mar 1, 2011 at 16:08
  • How are you checking the values of the variables? Commented Mar 1, 2011 at 16:11

1 Answer 1

7

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?

Sign up to request clarification or add additional context in comments.

2 Comments

I'll recheck again, just to be 200% sure.
You're right, data was the concern. Obviously the example I posted above was a simplification of the real thing, but I had an issue with the where clause. Thanks again!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.