How to find if the Column Exists in a table in SQL Server?

If you are looking to find if the column exists in a table in SQL Server, here’s a simple query to it.

Assume that the table name is “Articles” and the column name is “AbundantCodeType”, below is a sample query to know if the column exists in SQL Server.

How to find if the Column Exists in a table in SQL Server ?

If exists(select * from sys.columns

where Name = N'AbundantCodeType' and Object_ID = Object_ID(N'Articles'))

begin

/* Perform the logic since the column exists */

End
Tags :

Leave Your Comment

Liked this content?. Please spread the word :)