Friday, October 29, 2010

Check if given column exists in a table in SQL Server database

Following SQL statement checks to see if column “Address” exists in the “Employee” table. If the column does not exist it adds that column.

If Not Exists (Select * From Information_Schema.Columns 
Where Table_Name = 'Employee' And Column_Name = 'Address')
Alter Table Employee Add Address nvarchar(200)


No comments: