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

See Whether A Table Exists Or Not

Status
Not open for further replies.

arpan

Programmer
Oct 16, 2002
336
IN
How do I find out whether a table exists or not in SQL Server? What I want to do is if the table exists, then DROP it while a stored procedure is being executed.

Thanks,

Arpan
 
Check for the table using IF EXISTS as in:
Code:
if exists 
(select TABLE_NAME from INFORMATION_SCHEMA.TABLES 
where TABLE_NAME='Categories' and 
TABLE_SCHEMA='dbo'
)
[DROP STATEMENTS HERE]

ELSE
[do other stuff]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top