How to check if a column exists in a table in SQL Server ?

If you want to find out if a column exists in a SQL Server table , you can use the sys.columns table and specify the name of the column and table as parameter.

How to check if a column exists in a table in SQL Server ?

For example , you want to find out if the GroupName column exists in the table “HumanResources.Department” table , your query will look this

Use AdventureWorks2014
GO
SELECT *
FROM sys.columns 
WHERE Name      = N'GroupName'
AND Object_ID = Object_ID(N'HumanResources.Department') 

The result would be details of the column.

How to check if a column exists in a table in SQL Server ?