IF EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Bargeh' AND COLUMN_NAME = 'CodeFarayandVisitor') begin print 'Ok' end else begin alter table Bargeh Add CodeFarayandVisitor bigint foreign key references Tafsili(code) end go IF EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'BargehDetail' AND COLUMN_NAME = 'CodeFarayandVisitor') begin print 'Ok' end else begin alter table BargehDetail Add CodeFarayandVisitor bigint foreign key references Tafsili(code) end