Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Check if a table exists in the database

Author  Topic 

dataforums
Starting Member

14 Posts

Posted - 2005-05-18 : 10:05:05
Hi,
I am trying to create dynamic tables but I want to check if they already exists in the database. Can anyone please tell me how to check if a table already exists in a sql server database??

Thanks in advance.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-05-18 : 10:11:07
if exists(select * from sysobjects where name='tablename')
print 'Table Exists'
else
print 'Table does not exist'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

dataforums
Starting Member

14 Posts

Posted - 2005-05-18 : 13:26:25
Thanks!!
Go to Top of Page
   

- Advertisement -