September 2, 2010 at 8:05 am
I have a stored procedure with a local variable that i want to set to a result from a query, like this
DECLARE @ExistingID AS bigint
SELECT @ExistingID = ID FROM Table WHERE ReferenceID = @ReferenceID;
what would the value of @ExistingID be if there was no data found ? would it be null ? or 0, or some other value ?
** ReferenceID is a string passed into the SP as a parameter
September 2, 2010 at 8:14 am
I would suggest adding a "select @ExistingID" to the end of your code, and see what you get.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
September 2, 2010 at 8:16 am
If no records is found based on your WHERE clause, you'll get a null value. But as stated above, do a select / print on that variable afterwards to confirm
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply