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
Monday, November 1, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment