--drop table GardeshTamirat --drop table TamiratDetailDarkhastGeteh --drop table Tamirat if Exists(SELECT * FROM information_schema.tables where Table_name = 'Tamirat') begin print 'true' end else begin create table Tamirat ( Code int primary key, CodeTamirat int not null, TarikhPaziresh int not null, TarikhTahvil int not null, NahvePaziresh smallint not null, SaatPaziresh nvarchar (5), CodeKhadamat bigint references tafsili(Code) not null, CodeMoshtari bigint references tafsili(Code) not null, CodeFarayandMoshtari int References Farayand(Code), NameMoshtari nvarchar(100), TelMoshtari nvarchar(100), MobileMoshtari nvarchar(100), AdressMoshtari nvarchar(200), CodeSandoogh bigint references Tafsili(Code) not null, CodeFarayandSandoogh int references Farayand(Code), CodeKala int references Kala(Code) not null, SerialKala nvarchar(100), ShomarehKontor nvarchar(100), ShomarehModel nvarchar(100), EibDastgah nvarchar(500), Sharh nvarchar(500), Motallaghat nvarchar(500), MablaghBeiaaneh decimal(19,4) not null, MablaghHazineh decimal(19,4) not null, CodeTamirKar bigint references tafsili(Code), CodeFarayandTamirKar int References Farayand(Code), CodeHazinehTamirKar bigint References Tafsili(Code), MablaghTamirKar decimal (19,4), DarsadTamirKar float , HasGaranti bit not null, TarikhStartGaranti int not null default 0, TarikhEndGaranti int not null default 0, CodeSherkatGaranti bigint references Tafsili(Code), VaziatBargeh smallint not null, VaziatTamir smallint not null, DarkhastGhete bit not null, TarikhSabt int not null, SaatSabt smallint not null, CodeKarbar int References Karbar(Code) not null, CodeBargeh int ) end go if Exists(SELECT * FROM information_schema.tables where Table_name = 'TamiratDetailDarkhastGeteh') begin print 'true' end else begin create Table TamiratDetailDarkhastGeteh ( Code int primary key identity(1,1), CodeTamirat int References Tamirat(Code) not null, CodeAnbar int References Anbar(Code) not null, CodeKala int References Kala(Code) not null, Meghdar1 float not null, Meghdar2 float not null, Tedad float not null, Gheimat decimal(19,4) not null ) end go if Exists(SELECT * FROM information_schema.tables where Table_name = 'GardeshTamirat') begin print 'true' end else begin create table GardeshTamirat ( Code int Primary key identity(1,1), CodeParent int references Tamirat(Code) not null, Tarikh int not null, Saat nvarchar(5) not null, NazarTeknesian nvarchar(500), Sharh nvarchar(500), CodeTafsiliBedehKar bigint references Tafsili(Code), CodeFarayandBedehKar int References Farayand(Code), CodeTafsiliBestanKar bigint references Tafsili(Code), CodeFarayandBestanKar int References Farayand(Code), Mablagh decimal(19,4) not null DEFAULT 0.0, VaziatGardesh smallint not null, TatikhSabt int not null, SaatSabt smallint not null, CodeKarbar int References Karbar(Code) not null ) END