mikaelsnavy
7/15/2015 - 10:29 PM

Add column if it doesn't already exist

Add column if it doesn't already exist

IF EXISTS (
  SELECT * 
  FROM   sys.columns 
  WHERE  object_id = OBJECT_ID(N'[dbo].[Person]') 
         AND name = 'ColumnName'
)
ALTER TABLE dbo.Person
ADD ColumnName VARCHAR(64)