IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_fieldinfo]') AND type = 'U')
CREATE TABLE [dbo].[mps_fieldinfo]
(
    [fldi_id] int NOT NULL IDENTITY(1, 1),
    [fldi_cmpid] int NULL DEFAULT((0)),
    [fldi_tbtype] varchar(10) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [fldi_tbid] int NULL DEFAULT((0)),
    [fldi_ord2tag] int NULL DEFAULT((0)),
    [fldi_database] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [fldi_tbname] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [fldi_fieldname] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [fldi_fieldcaption] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [fldi_system] int NULL DEFAULT((1)),
    [fldi_datatype] varchar(10) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [fldi_ident] int NULL DEFAULT((1)),
    [fldi_size] int NULL DEFAULT((0)),
    [fldi_decimal] int NULL DEFAULT((4)),
    [fldi_default] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [fldi_hidden] int NULL DEFAULT((1)),
    [fldi_key] varchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [fldi_index] varchar(500) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [fldi_updated] int NULL DEFAULT((0)),
    [fldi_oldname] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [fldi_copied] int NULL DEFAULT((0)),
    [fldi_changed] int NULL DEFAULT((0)),
    CONSTRAINT [PK_MPS_FIELDINFO] PRIMARY KEY ([fldi_id] ASC)
)

IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID('[dbo].[mps_fieldinfo]') AND name = 'mps_fieldinfo_updated')
CREATE NONCLUSTERED INDEX [mps_fieldinfo_updated] ON [dbo].[mps_fieldinfo]([fldi_updated] ASC)

IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID('[dbo].[mps_fieldinfo]') AND name = 'mps_fieldinfo_copied')
CREATE NONCLUSTERED INDEX [mps_fieldinfo_copied] ON [dbo].[mps_fieldinfo]([fldi_copied] ASC)