if Exists(SELECT * FROM information_schema.tables where Table_name = 'MohsebehEstelak') begin print 'true' end else begin create table MohsebehEstelak ( Code int primary Key, CodeBargeh int not null, Tarikh int not null, Vaziat smallint not null, Sharh nvarchar(500), CodeKarbar int references Karbar(code) not null, TarikhSabt int not null, SaatSabt smallint not null ) end if Exists(SELECT * FROM information_schema.tables where Table_name = 'MohsebehEstelakDetail') begin print 'true' end else begin create table MohsebehEstelakDetail ( Code int primary Key identity(1,1), CodeParent int references MohsebehEstelak(Code) not null, CodeAmval bigint references tafsili(code) not null, CodeTafsili bigint references tafsili(code) not null, CodeFarayandTafsili int references Farayand(code) , Mablagh decimal(19,4) not null ) end