Wednesday 25 July 2012

Alter column script with exists()


if not Exists(select * from sys.columns where Name = N'BlackListed' 
            and Object_ID = Object_ID(N'GN_Contacts'))
begin
    Alter table GN_Contacts
    Add
    BlackListed bit default 0 not null,
    BlackListedOn datetime,
    BlackListedRemarks Varchar(400);
end
GO

No comments:

Post a Comment