Gouache painting of a row of bare hat stands with one holding a single red hat

How to Check if a Column Exists in a SQL Server Table

To check if a column exists in a SQL Server table, call COL_LENGTH and test the result for NULL, or look the column up in sys.columns. This post compares the three common checks, including the schema trap in INFORMATION_SCHEMA and the three-part name for another database. It ends with a script that adds a column only when it is missing, and the batch rule that makes that script fail if you ignore it.

Read More