Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

The value of variable is disappearing in stored procedure Expand / Collapse
Author
Message
Posted Friday, April 30, 2010 11:01 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, April 30, 2010 11:01 AM
Points: 1, Visits: 13
Hi!!!

The variable is initialized in a stored procedure with the value present in a table.
It is disappearing at later point of time.The data type of variable is Char.
Tried to print the value, it displays as NULL.
Please help me...
Post #913915
Posted Friday, April 30, 2010 11:15 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 2:09 PM
Points: 12,905, Visits: 32,166
chaturvedi.garima (4/30/2010)
Hi!!!

The variable is initialized in a stored procedure with the value present in a table.
It is disappearing at later point of time.The data type of variable is Char.
Tried to print the value, it displays as NULL.
Please help me...


so....are you going to show us the stored procedure? can't really help without that; there must be something changing the data if you say it was initialized to some value, or it was not assigned a value from your table when ou thought it was.


Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #913928
Posted Friday, April 30, 2010 11:18 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, October 16, 2014 11:58 AM
Points: 1,142, Visits: 2,689
chaturvedi.garima (4/30/2010)
Hi!!!

The variable is initialized in a stored procedure with the value present in a table.
It is disappearing at later point of time.The data type of variable is Char.
Tried to print the value, it displays as NULL.
Please help me...


I second the part of needing to see the code. If there are lots of lines in the code you may need to Keep trying to put print statements in various spots to see what the value is to try by process of elimination find where you're assigning NULL to it.


---------------------------------------------------------------------
Use Full Links:
KB Article from Microsoft on how to ask a question on a Forum
Post #913933
Posted Friday, April 30, 2010 11:22 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, June 19, 2012 9:31 AM
Points: 421, Visits: 78
Is it possible that the statement retrieving the value from the table does not actually return a row..? This would make the variable NULL.

As the other posts have said, we are happy to help if you post your code.
Post #913937
Posted Friday, April 30, 2010 11:24 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 1:15 PM
Points: 863, Visits: 7,352
Just a shot in the dark without being able to see the code, but if you're using the variable in any concatenation operation, you might want to set the CONCAT_NULL_YIELDS_NULL option off and try it again. With the option on, any concatenation with a NULL will change the entire string to NULL.



And then again, I might be wrong ...
David Webb
Post #913939
Posted Friday, April 30, 2010 11:35 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Wednesday, September 19, 2012 8:39 AM
Points: 595, Visits: 1,226
Just FYI, CONCAT_NULL_YIELDS_NULL will always be on in future versions of SQL Server.

Converting oxygen into carbon dioxide, since 1955.

Post #913950
Posted Friday, April 30, 2010 6:55 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 6:30 PM
Points: 35,370, Visits: 31,911
David Webb-200187 (4/30/2010)
Just a shot in the dark without being able to see the code, but if you're using the variable in any concatenation operation, you might want to set the CONCAT_NULL_YIELDS_NULL option off and try it again. With the option on, any concatenation with a NULL will change the entire string to NULL.


Oh... absolutely correct but I wouldn't do it that way especially since it's already known that future versions of SQL Server will not have the option of turning it off. Better to use ISNULL() for such things.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #914160
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse