Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
HowTo: Release a Table variable
Message
From
13/01/2005 16:48:51
 
 
To
13/01/2005 14:06:07
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
00976391
Message ID:
00976960
Views:
23
To wrap this up (hopefully!), I received a few responses from SQL MVPs from one of the SQL newsgroups.

The consensus was that no one expected variables could be scoped in a BEGIN...END block (yet also acknowledged that BOL indicates otherwise). One person stated he might contact MS about this.

The general recommendation (no surprise) was to declare local variables at the top of the procedure.

In addition to Bonnie's test, someone also demonstrated that declaring the same local variable inside two different BEGIN...END blocks generated an error that the variable had already been declared.

So it seems that variables inside a BEGIN...END block are created regardless. At the very least (IMHO), the docs could be a little clearer about this, and should more consistently state the actual scope.

Kevin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform