Monday, November 1, 2010

How to determine whether a table is exist or not in Sql Server database

In some cases we need to identify whether a table is exist or not in a sql server database. This is very simple & now i am sharing with you. Hope it will works like a handbook for you.













Query:
IF EXISTS (SELECT 1
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE='BASE TABLE'
AND TABLE_NAME='tablename')
SELECT 'table exists.'
ELSE
SELECT 'table does not

No comments:

Post a Comment