IF not EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'AccountItem' AND COLUMN_NAME = 'AI_ID') begin alter table dbo.AccountItem add AI_ID int references dbo.AccountItem (ID) null end ; IF not EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'AccountItem' AND COLUMN_NAME = 'Dom_ID_RemindType') begin alter table dbo.AccountItem add Dom_ID_RemindType int references dbo.domain (ID) null end ; IF not EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'GroohAccountItem' AND COLUMN_NAME = 'Dom_ID_Type') begin alter table dbo.GroohAccountItem add Dom_ID_Type int references dbo.Domain (ID) not null default -1 end