IF ((SELECT COUNT(*) FROM matter WHERE ID = -1) = 0) begin insert into matter(ID,Dom_ID_Type,Code,FC_ID,Org_ID,Dom_ID_Status,TarikhSabt,SaatSabt,CodeKarbar) values(-1,-1,-1,30,8,455,14000101,1200,1) end ; IF not EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'product' AND COLUMN_NAME = 'Mat_ID') begin alter table product add Mat_ID bigint references matter (ID) not null default -1 end ; IF not EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'product' AND COLUMN_NAME = 'FC_ID') begin alter table product add FC_ID int references Finance_Cycle (ID) not null default -1 end ; IF not EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'product' AND COLUMN_NAME = 'Pro_ID_VahedMali') begin alter table product add Pro_ID_VahedMali int references otherProperties (ID) not null default -1 end