if Exists(SELECT * FROM information_schema.tables where Table_name = 'UseProductionKala') begin print 'true' end else begin create table UseProductionKala ( Code int primary key , CodeBargeh int not null, noe smallint not null, Tarikh int not null, CodeTafsili bigint references tafsili(Code) not null, CodeFarayandTafsili int references Farayand(Code), CodeProjeh bigint references tafsili(Code), Sharh nvarchar(300), Vaziat smallint not null, CodeKarbar int not null foreign key references Karbar(code), SaatSabt smallint not null, TarikhSabt int not null ) end if Exists(SELECT * FROM information_schema.tables where Table_name = 'UseProductionKalaDetail') begin print 'true' end else begin create table UseProductionKalaDetail ( Code int primary key identity(1,1), CodeBargeh int references UseProductionKala(Code) not null, CodeAnbar int references Anbar(Code) not null, CodeKala int references Kala(Code) not null, Meghdar1 float not null default 1, Meghdar2 float not null default 1, Tedad float not null default 1, Mablagh decimal(19,4) not null default 0, Sharh nvarchar(300), ) end