IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_warehouse_data]') AND type = 'U')
CREATE TABLE [dbo].[mps_warehouse_data]
(
    [whg_id] bigint NOT NULL IDENTITY(1, 1),
    [whg_whid] int NULL DEFAULT((0)),
    [whg_prdid] bigint NULL DEFAULT((0)),
    [whg_unit] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [whg_batch] varchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [whg_amount] decimal(18, 4) NULL DEFAULT((0)),
    [whg_baseamount] decimal(18, 4) NULL DEFAULT((0)),
    [whg_fee] decimal(18, 4) NULL DEFAULT((0)),
    [whg_outprice] decimal(18, 4) NULL DEFAULT((0)),
    [whg_date] datetime NULL DEFAULT(getdate()),
    [whg_expire] datetime NULL DEFAULT('1900-01-01'),
    [whg_note] nvarchar(200) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [whg_ready] decimal(18, 4) NULL DEFAULT((0)),
    [whg_suspend] decimal(18, 4) NULL DEFAULT((0)),
    [whg_location] nvarchar(200) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [whg_inprice] decimal(18, 4) NULL,
    [whg_tag] int NULL,
    [whg_baseready] decimal(18, 4) NULL,
    [whg_basesuspend] decimal(18, 4) NULL,
    [whg_inamount] decimal(18, 4) NULL DEFAULT((0)),
    [whg_infee] decimal(18, 4) NULL DEFAULT((0)),
    [whg_outamount] decimal(18, 4) NULL DEFAULT((0)),
    [whg_outfee] decimal(18, 4) NULL DEFAULT((0)),
    CONSTRAINT [PK_mps_warehouse_data] PRIMARY KEY ([whg_id] ASC)
)


IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID('[dbo].[mps_warehouse_data]') AND name = 'mps_warehouse_data')
CREATE NONCLUSTERED INDEX [mps_warehouse_data] ON [dbo].[mps_warehouse_data]([whg_whid] ASC,[whg_prdid] ASC)