Friday, January 11, 2019

Check to see if a column exists at a table in T-SQL!

IF NOT EXISTS(
   SELECT * FROM INFORMATION_SCHEMA.COLUMNS
   WHERE TABLE_NAME = 'Customer' AND COLUMN_NAME = 'Address2'
   ) ALTER TABLE Customer ADD Address2 varchar(255) null

No comments:

Post a Comment