|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Can I release temp SQL Tables?In Query Analyzer I am creating a Select statement using temp tables. For a
simple example: Select abc.def into #tmptable from ABCTable. If I make changes to the query and then rerun it, it tells me that the object (which is the temp table) already exist in the database. I have to close my Query Analyzer window and then reopen it. So my question is this: Is there a command that I can include in the Query Analyzer window that will release the Temp Table without having to close the window? DROP TABLE #TABLENAME
Show quote "Preacher Man" <nospam> wrote in message news:OaUixWGRGHA.4952@TK2MSFTNGP09.phx.gbl... > In Query Analyzer I am creating a Select statement using temp tables. For > a simple example: > > Select abc.def into #tmptable from ABCTable. > > If I make changes to the query and then rerun it, it tells me that the > object (which is the temp table) already exist in the database. I have to > close my Query Analyzer window and then reopen it. > > So my question is this: Is there a command that I can include in the > Query Analyzer window that will release the Temp Table without having to > close the window? > drop table #tmptable
Show quote "Preacher Man" <nospam> wrote in message news:OaUixWGRGHA.4952@TK2MSFTNGP09.phx.gbl... > In Query Analyzer I am creating a Select statement using temp tables. For > a simple example: > > Select abc.def into #tmptable from ABCTable. > > If I make changes to the query and then rerun it, it tells me that the > object (which is the temp table) already exist in the database. I have to > close my Query Analyzer window and then reopen it. > > So my question is this: Is there a command that I can include in the > Query Analyzer window that will release the Temp Table without having to > close the window? > Thanks everyone for the quick response.
Show quote "Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message news:ejKaNaGRGHA.4920@tk2msftngp13.phx.gbl... > drop table #tmptable > > > > "Preacher Man" <nospam> wrote in message > news:OaUixWGRGHA.4952@TK2MSFTNGP09.phx.gbl... >> In Query Analyzer I am creating a Select statement using temp tables. >> For a simple example: >> >> Select abc.def into #tmptable from ABCTable. >> >> If I make changes to the query and then rerun it, it tells me that the >> object (which is the temp table) already exist in the database. I have >> to close my Query Analyzer window and then reopen it. >> >> So my question is this: Is there a command that I can include in the >> Query Analyzer window that will release the Temp Table without having to >> close the window? >> > > and u can put a check in too :
IF OBJECT_ID ('tempdb..#testtemp') IS NOT NULL BEGIN DROP TABLE #testtemp END CREATE TABLE #testtemp (numb int) INSERT #testtemp VALUES (1) INSERT #testtemp VALUES (1) Show quote "Preacher Man" <nospam> wrote in message news:OaUixWGRGHA.4952@TK2MSFTNGP09.phx.gbl... > In Query Analyzer I am creating a Select statement using temp tables. For > a simple example: > > Select abc.def into #tmptable from ABCTable. > > If I make changes to the query and then rerun it, it tells me that the > object (which is the temp table) already exist in the database. I have to > close my Query Analyzer window and then reopen it. > > So my question is this: Is there a command that I can include in the > Query Analyzer window that will release the Temp Table without having to > close the window? > |
|||||||||||||||||||||||