How to check if a column exists in SQL Server table| sql server check if exists column name.

Try this:
IF EXISTS(SELECT * FROM sys.columns 
          WHERE Name = N'columnName'
          AND Object_ID = Object_ID(N'schemaName.tableName'))
BEGIN
    -- Exists
END

Post a Comment

0 Comments