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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I deallocate/erase a variable and then reuse it? 1

Status
Not open for further replies.

joelwenzel

Programmer
Jun 28, 2002
448
I need a way to do something like

Delare @a int
set @a = 5

...

Delete @a
Declare @a varchar(30)
Set @a = 'asdgas'


Any ideas?
 
I'm pretty sure you can't do that. Is there any particular reason that you need it this way instead of simply creating another variable to use?

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Issuing a go statement should do the trick.

Code:
declare 
	@field int 
	set @field = 2
	print convert(varchar, @field)
go

declare 
	@field varchar(10)
	set @field = 'test'
	print @field

Regards,
AA
 
Works well outside stored procedures :>

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
The go did it! Thanks.

gmmastros, I agree, it sounds liek a stupid idea. But I am writing a program that generates a script and I am not always sure of the variable names taht are in the script so that is why I'm trying to erase them
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top