Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
HowTo: Release a Table variable
Message
De
13/01/2005 12:37:07
 
 
À
13/01/2005 10:24:33
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
00976391
Message ID:
00976839
Vues:
20
Kevin,

Magnus was referring to the entry in BOL about the scope being contained within BEGIN/END blocks. In BOL, search on variables, then click on the "declaring" topic ...down about mid-way thru the topic, under remarks is this:

The scope of a local variable is the batch, stored procedure, or statement block in which it is declared. For more information about using local variables in statement blocks, see Using BEGIN...END.

Which is what Magnus posted in his reply. And why it doesn't seem to work according to the BOL is anybody's guess. <g>

~~Bonnie




>Hey, Magnus/Bonnie,
>
>In BOL, if you search on "local variables" and select the 2nd topic (Transact-SQL variables), you'll find the following:
>
>The scope of a variable is the range of Transact-SQL statements that can reference the variable. The scope of a variable lasts from the point it is declared until the end of the batch or stored procedure in which it is declared. For example, this script generates a syntax error because the variable is declared in one batch and referenced in another:
>
>
>DECLARE MyVariable INT
>SET @MyVariable = 1
>GO -- This terminates the batch.
>-- @MyVariable has gone out of scope and no longer exists.
>
>-- This SELECT statement gets a syntax error because it is
>-- no longer legal to reference @MyVariable.
>SELECT *
>FROM Employees
>WHERE EmployeeID = @MyVariable
>
>
>Was there a specific topic that indicated something different?
>
>Thanks,
>Kevin
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform