if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_StoreTranaction_StoreCategory]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1) ALTER TABLE [dbo].[StoreTranaction] DROP CONSTRAINT FK_StoreTranaction_StoreCategory GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_StoreTranaction_StoreConsumer]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1) ALTER TABLE [dbo].[StoreTranaction] DROP CONSTRAINT FK_StoreTranaction_StoreConsumer GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_StoreTranaction_StoreDocument]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1) ALTER TABLE [dbo].[StoreTranaction] DROP CONSTRAINT FK_StoreTranaction_StoreDocument GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_StoreTranaction_StoreSupplier]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1) ALTER TABLE [dbo].[StoreTranaction] DROP CONSTRAINT FK_StoreTranaction_StoreSupplier GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_StoreTranaction_StoreTransType]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1) ALTER TABLE [dbo].[StoreTranaction] DROP CONSTRAINT FK_StoreTranaction_StoreTransType GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_StoreCategory_StoreUnite]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1) ALTER TABLE [dbo].[StoreCategory] DROP CONSTRAINT FK_StoreCategory_StoreUnite GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[StoreCategory]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[StoreCategory] GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[StoreConsumer]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[StoreConsumer] GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[StoreDocument]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[StoreDocument] GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[StoreSupplier]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[StoreSupplier] GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[StoreTranaction]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[StoreTranaction] GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[StoreTransType]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[StoreTransType] GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[StoreUnite]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[StoreUnite] GO CREATE TABLE [dbo].[StoreCategory] ( [CatCode] [int] NOT NULL , [CatName] [nvarchar] (50) COLLATE Arabic_CI_AS NOT NULL , [CatReOrder] [int] NULL , [CatUnite] [int] NOT NULL ) ON [PRIMARY] GO CREATE TABLE [dbo].[StoreConsumer] ( [ConsumerCode] [int] NOT NULL , [ConsumerName] [nvarchar] (50) COLLATE Arabic_CI_AS NOT NULL ) ON [PRIMARY] GO CREATE TABLE [dbo].[StoreDocument] ( [DocumentCode] [int] NOT NULL , [DocumentName] [nvarchar] (50) COLLATE Arabic_CI_AS NULL ) ON [PRIMARY] GO CREATE TABLE [dbo].[StoreSupplier] ( [SupplierCode] [int] NOT NULL , [SupplierName] [nvarchar] (50) COLLATE Arabic_CI_AS NOT NULL , [SupplierTel] [nvarchar] (50) COLLATE Arabic_CI_AS NULL ) ON [PRIMARY] GO CREATE TABLE [dbo].[StoreTranaction] ( [TransDate] [datetime] NOT NULL , [TransType] [int] NOT NULL , [TransDocNo] [int] NOT NULL , [TransCatCode] [int] NOT NULL , [TransPaperType] [int] NOT NULL , [TransValue] [float] NOT NULL , [TransPrice] [float] NOT NULL , [TransTargetPlace] [int] NULL , [TransFromPlace] [int] NULL , [TransStationery] [numeric](10, 0) NULL , [TransBalance] [int] NOT NULL , [TransCode] [int] IDENTITY (1, 1) NOT NULL , [TransNote] [nvarchar] (500) COLLATE Arabic_CI_AS NULL ) ON [PRIMARY] GO CREATE TABLE [dbo].[StoreTransType] ( [TransTypeCode] [int] NOT NULL , [TranTypeName] [nvarchar] (50) COLLATE Arabic_CI_AS NULL ) ON [PRIMARY] GO CREATE TABLE [dbo].[StoreUnite] ( [UniteCode] [int] NOT NULL , [UniteName] [nvarchar] (50) COLLATE Arabic_CI_AS NOT NULL ) ON [PRIMARY] GO