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

how do I drop a table if its exists 2

Status
Not open for further replies.

DougP

MIS
Joined
Dec 13, 1999
Messages
5,985
Location
US
this is what I have so far
I know its in the 'benchmark' database

if exists table1 in information_schema.tables
drop table table1


DougP, MCP, A+
 
Code:
if Exists ( SELECT * from mydb.dbo.Sysobjects
WHERE xtype='U' and name='table1')
begin
Drop Table table1
End

-DNG
 
thank you
get a star

DougP, MCP, A+
 
Just another way to skin that cat:

if object_id('tempdb..#TempTable') is not null
drop table #TempTable
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top