Link to home
Start Free TrialLog in
Avatar of Phil Chapman
Phil ChapmanFlag for United States of America

asked on

Does A Table Exist In A Database

I need a query that will check to see if a table ( PaymentType ) exist in a database.  If it does exist the query needs to return a 1 if the table does not exist return a 0.

Any help in creating this query will be appreciated.
ASKER CERTIFIED SOLUTION
Avatar of computerstreber
computerstreber
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tripyre
Tripyre

IF OBJECT_ID ('AdventureWorks.dbo.AWBuildVersion','U') IS NOT NULL
Print 'Table Exists'
ELSE
Print 'Table Does Not Exists'

where 'AdventureWorks.dbo.AWBuildVersion' is the object name and 'U' is the object type which represents a table

http://www.sqlservercurry.com/2007/12/check-if-database-or-table-exists-using.html
Avatar of Phil Chapman

ASKER

Thanks