-- Check if Table Exists
IF (EXISTS (SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'Schema'
AND TABLE_NAME = 'Table'))
BEGIN
PRINT 'TABLE EXISTS'
END
-- Check if Table NOT Exists
IF (NOT EXISTS (SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'Schema'
AND TABLE_NAME = 'Table'))
BEGIN
PRINT 'TABLE NOT EXISTS'
END
-- Check if Column Exists
IF COL_LENGTH('Schema.Table', 'Column') IS NOT NULL
BEGIN
PRINT 'COLUMN EXISTS'
END
-- Check if Column NOT Exists
IF COL_LENGTH('Schema.Table', 'Column') IS NULL
BEGIN
PRINT 'COLUMN NOT EXISTS'
END