September 10, 2002 at 5:08 pm
Are we able to declare global variables? I am building a dynamic SQL statement and I want to use the variable declared in the first dynamic sql statement to be used in the second dynamic sql statement. Is this possible?
September 10, 2002 at 5:19 pm
One way to accomplish this is to create dynamic sql that is sets a local variable via sp_executesql using the out parm, then use that variable in the next dynamic sql statement. Check out this example of how to set the local variable via sp_execute_sql:
http://www.geocities.com/sqlserverexamples/#dyn1
-------------------------
Gregory Larsen, DBA
If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples
Gregory A. Larsen, MVP
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply