Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Local Variables

Author  Topic 

purnima.m
Starting Member

3 Posts

Posted - 2006-03-04 : 03:24:43
Hi ,

I am new to SQL Server.

1.Can anyone please tell me
the scope of local variables used in SQL Scripts?

2.If a local variable is being used in a Cursor's
while loop do we need to Reintialise the local variables
to prevent old values being retained?

Thank You

Punima

Punima

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-03-04 : 03:35:36
It depends where you are declaring your local variable.
The scope of the local variable is limited upto the batch.

if you are you have declared the variable at the top of the stored procedure then it can be access through out the procedure..


Sucess Comes to those who Believe in Beauty of their Dream..
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-03-05 : 01:02:23
for the benefit of the readers, more answer of this duplicated post here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=62710

----------------------------------
'KH'


Go to Top of Page
   

- Advertisement -