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
 SQL Server Administration (2000)
 Sql query To locate tables

Author  Topic 

Keshaba
Yak Posting Veteran

52 Posts

Posted - 2008-12-29 : 07:09:24
I am using Sql server 2005 Express As Back end.How shall I write a query wheather a Table name EmployeeMaster in the database name MediaSys Exist or not.

Keshab

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-12-29 : 07:22:55
quote:
Originally posted by Keshaba

I am using Sql server 2005 Express As Back end.How shall I write a query wheather a Table name EmployeeMaster in the database name MediaSys Exist or not.

Keshab



if exists(select 1 from MediaSys..sysobjects where name ='EmployeeMaster')
print 'exists'
else
print 'doesnt exist'
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-29 : 12:21:23
or use this

IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='EmployeeMaster' AND TABLE_TYPE='BASE TABLE')
PRINT 'TABLE EXISTS'
ELSE
print 'TABLE DOESNT EXIST'
Go to Top of Page
   

- Advertisement -