Thread: MS SQL Server General Questions/How to check if data field (column) exists in the database

How to check if data field (column) exists in the database
DECLARE @col_length smallint
SELECT @col_length=COL_LENGTH('PrintServices.dbo.Messages','Envelope_Size')

if @col_length is NULL
  print N'We do not have this column in the table'
else
  print N'We do have this column in the table'