SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


The value of variable is disappearing in stored procedure


The value of variable is disappearing in stored procedure

Author
Message
chaturvedi.garima
chaturvedi.garima
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 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.Sad
Please help me...
Lowell
Lowell
SSC Guru
SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)

Group: General Forum Members
Points: 184429 Visits: 41569
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.Sad
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
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Trey Staker
Trey Staker
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2266 Visits: 2788
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.Sad
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
nabidavid
nabidavid
SSChasing Mays
SSChasing Mays (623 reputation)SSChasing Mays (623 reputation)SSChasing Mays (623 reputation)SSChasing Mays (623 reputation)SSChasing Mays (623 reputation)SSChasing Mays (623 reputation)SSChasing Mays (623 reputation)SSChasing Mays (623 reputation)

Group: General Forum Members
Points: 623 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. ;-)
David Webb-CDS
David Webb-CDS
SSCrazy Eights
SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)SSCrazy Eights (9.6K reputation)

Group: General Forum Members
Points: 9588 Visits: 8587
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
Steve Cullen
Steve Cullen
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2771 Visits: 1226
Just FYI, CONCAT_NULL_YIELDS_NULL will always be on in future versions of SQL Server.

Converting oxygen into carbon dioxide, since 1955.


Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (510K reputation)SSC Guru (510K reputation)SSC Guru (510K reputation)SSC Guru (510K reputation)SSC Guru (510K reputation)SSC Guru (510K reputation)SSC Guru (510K reputation)SSC Guru (510K reputation)

Group: General Forum Members
Points: 510806 Visits: 44296
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.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search