IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'dbo'
AND TABLE_NAME = 'Page'))
BEGIN
PRINT 'Table exists'
END
ELSE
BEGIN
PRINT 'Table does not exists'
END
IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'dbo'
AND TABLE_NAME = 'Page'
AND COLUMN_NAME = 'State'))
BEGIN
PRINT 'Column exists'
END
ELSE
BEGIN
PRINT 'Column does not exists'
END
31500cookie-checkMSSQL check if Table or Column Exists