Skip to content
  • There are no suggestions because the search field is empty.

T SQL Script: Check if a column exists in a table

T SQL Script: Check if a column exists in a table

-- Check if a column exists in a table

IF EXISTS (
    SELECT 1
    FROM sys.columns
    WHERE Name = N'ReceiptNo'
      AND Object_ID = Object_ID(N'dbo.tblMemorialInformation')
)
BEGIN
    PRINT 'Column exists';
END
ELSE
BEGIN
    PRINT 'Column does NOT exist';
END