Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can I use a global var. in a query with several batches?

Status
Not open for further replies.

rtdvoip

Programmer
Aug 29, 2003
27
US
Hiya fellas,

Is it possible to set a global variable that will
remain until a second batch query is executed...

delcar @@var int
set @@var = <something>
go
query..

go
query...


It says that the var is not declared. Is there some way around this?

thanks in advance for your help,
rtdvoip
 
Are both of your queries w/in the same SP? If so, a local var will do just fine too.

Thanks

J. Kusch
 
I did not set it up in a SP = SQL Procedure?
just in a text query that I import into the query analyzer
where I want to run it.
If I try to create a procedure then the code after the first
go is missing.
 
Correct ... The GO executes the previous code entered. you would have to drop the &quot;GO&quot;s in between each batch first.

Thanks

J. Kusch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top