if not Exists(SELECT * FROM information_schema.tables where Table_name = 'StoreDocument') begin create table dbo.StoreDocument ( ID int primary key, Code int not null, Mat_ID bigint references matter(ID) not null, FC_ID int references Finance_Cycle(ID) not null, Pro_ID_VahedMali int references OtherProperties(ID) not null, Dom_ID_RowType int references domain(ID) not null, -- دستی، سیستمی Tarikh int not null, Saat int not null, Pro_ID_Anbar int references OtherProperties(ID) not null, Pro_ID_DocType int references OtherProperties(ID) not null, -- نوع: حواله مصرفی، حواله انتقال، رسید خرید و .... Description nvarchar(1000), Kar_ID_Creator int references karbar(ID) not null, TarikhSabt int not null, SaatSabt int not null ) end ; if not Exists(SELECT * FROM information_schema.tables where Table_name = 'StoreDocumentItem') begin create table dbo.StoreDocumentItem ( ID int primary key identity(1,1), SD_ID int references StoreDocument(ID) not null, SDI_ID int references StoreDocumentItem(ID) null, Kal_ID int references kala(ID) not null, Pro_ID_Unit int references OtherProperties(ID) not null, Dom_ID_Restoration int references domain(ID) not null, -- نو، مستعمل، اسقاط Quantity float not null, Price decimal(19,4) not null, Description nvarchar(1000), Kar_ID_Creator int references karbar(ID) not null, TarikhSabt int not null, SaatSabt int not null ) end ; if not Exists(SELECT * FROM information_schema.tables where Table_name = 'StoreDocumentItemRefrenceID') begin create table dbo.StoreDocumentItemRefrenceID ( ID int primary key identity(1,1), SDI_ID int references StoreDocumentItem(ID) not null, KDA_ID int references KalaDarAnbar(ID) null, BD_ID int references BargehDetail(ID) null, ProductDetail_ID int references ProductDetail(ID) null ) end