if not Exists(SELECT * FROM information_schema.tables where Table_name = 'Contract') begin create table [Contract] ( ID int primary key, Code int not null, Title nvarchar(1000), FC_ID int references finance_cycle(ID) not null, Pro_ID_VahedMali int references otherproperties(ID) not null, Pro_ID_Title int references otherproperties(ID) not null, Mat_ID bigint references Matter(ID) not null, Taf_ID bigint references Tafsili(ID) not null, -- طرف قرارداد StartDate int not null, EndDate int not null, [Description] nvarchar(max), Pro_ID_Type int references otherProperties(ID) not null, -- پيماني ، صوري ، فروش Dom_ID_Status int references domain(ID) not null, -- وضعیت قرارداد => Kar_ID_Creator int references karbar(ID) not null, TarikhSabt int not null, SaatSabt smallint not null ) end go if not Exists(SELECT * FROM information_schema.tables where Table_name = 'ContractItem') begin create table ContractItem ( ID int primary key, Con_ID int references [Contract](ID) not null, Mat_ID bigint references Matter(ID) not null, Dom_ID_RowType int references domain(ID) not null, -- خدمات | کالا Dom_ID_Service int references Domain (ID) not null, Taf_ID bigint references Tafsili(ID) null, -- آیدی خدمات Kal_ID int references Kala(ID) null, -- آیدی کالا Quantity float not null, Price decimal(19,4) not null, [Description] nvarchar(max), Kar_ID_Creator int references karbar(ID) not null, TarikhSabt int not null, SaatSabt smallint not null ) end