IF NOT EXISTS ( SELECT  * FROM  dbo.sysobjects WHERE  name = 'SummaryFactorDetails')
    BEGIN
                    
        CREATE TABLE [dbo].[SummaryFactorDetails]
            (
		[FactorId] [UNIQUEIDENTIFIER] NULL,
		[Id] [UNIQUEIDENTIFIER] NOT NULL,
		[WarehouseCode] [VARCHAR](3) NULL,
		[GoodCode] [VARCHAR](15) NOT NULL,
		[GoodQty1] [MONEY] NOT NULL,
		[GoodQty2] [MONEY] NULL,
		[UnitRelation] [REAL] NULL,
		[PurchasePrice] [MONEY] NULL,
		[MajorPrice] [MONEY] NULL,
		[SalesPrice] [MONEY] NULL,
		[ConsumerPrice] [MONEY] NULL,
                [Status] [CHAR](1) NULL,
		[IsDecimal] [BIT] NULL,
		[IsIncludesTax] [BIT] NULL,
		[IsCooperative] [BIT] NULL,
		[SyncTime] [DATETIME] NULL,
              CONSTRAINT [PK_SummaryFactorDetails] PRIMARY KEY CLUSTERED
                ( [Id] ASC )
            )
        ON  [PRIMARY];

        ALTER TABLE [dbo].[SummaryFactorDetails]  WITH CHECK ADD  CONSTRAINT [FK_SummaryFactorDetails_SummaryFactors] FOREIGN KEY([FactorId])
        REFERENCES [dbo].[SummaryFactors] ([Id])
        ON DELETE CASCADE;

ALTER TABLE SummaryFactorDetails ADD CONSTRAINT [DF_SummaryFactorDetails_Id ] DEFAULT (NEWID()) FOR Id
    END;