IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[order_240]') AND type = 'U')
CREATE TABLE [dbo].[order_240]
(
    [ord_bcid] int NOT NULL DEFAULT((0)),
    [ord_bizid] int NOT NULL DEFAULT((0)),
    [ord_branch] nvarchar(50) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT(''),
    [ord_cbid] bigint NOT NULL DEFAULT((0)),
    [ord_cmpid] int NOT NULL DEFAULT((0)),
    [ord_createbizids] nvarchar(200) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT(''),
    [ord_createcuid] int NOT NULL DEFAULT((0)),
    [ord_createdepart] nvarchar(50) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT(''),
    [ord_createdpid] int NOT NULL DEFAULT((0)),
    [ord_creator] nvarchar(50) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT(''),
    [ord_cuid] int NOT NULL DEFAULT((0)),
    [ord_date] datetime NOT NULL DEFAULT(getdate()),
    [ord_depart] nvarchar(50) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT(''),
    [ord_dpid] int NOT NULL DEFAULT((0)),
    [ord_empname] nvarchar(50) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT(''),
    [ord_enddate] datetime NOT NULL DEFAULT('1900-1-1'),
    [ord_fbizid] int NOT NULL DEFAULT((0)),
    [ord_finished] int NOT NULL DEFAULT((0)),
    [ord_fjbid] bigint NOT NULL DEFAULT((0)),
    [ord_ford2id] bigint NOT NULL DEFAULT((0)),
    [ord_ford2tag] int NOT NULL DEFAULT((0)),
    [ord_fordid] bigint NOT NULL DEFAULT((0)),
    [ord_ftype] varchar(10) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT(''),
    [ord_groupkey] char(32) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT(''),
    [ord_id] bigint NOT NULL IDENTITY(1, 1),
    [ord_key] varchar(30) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT(''),
    [ord_no] varchar(50) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT(''),
    [ord_noi] int NOT NULL DEFAULT((0)),
    [ord_rbizid] int NOT NULL DEFAULT((0)),
    [ord_rord2id] bigint NOT NULL DEFAULT((0)),
    [ord_rord2tag] int NOT NULL DEFAULT((0)),
    [ord_rordid] bigint NOT NULL DEFAULT((0)),
    [ord_rtype] varchar(10) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT(''),
    [ord_security] int NOT NULL DEFAULT((3)),
    [ord_status] nvarchar(30) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT(''),
    [ord_style] int NOT NULL DEFAULT((0)),
    [ord_template] nvarchar(50) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT(''),
    [ord_templateid] int NOT NULL DEFAULT((0)),
    [ord_title] nvarchar(100) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT(''),
    [ord_type] nvarchar(50) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT(''),
    [ord_updated] datetime NOT NULL DEFAULT(getdate()),
    [ord_dqyg] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ord_bgyg] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ord_dqygcuid] bigint NULL DEFAULT((0)),
    [ord_bgygcuid] bigint NULL DEFAULT((0)),
    [ord_bgyy] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ord_dqbmsyrcuid] bigint NULL DEFAULT((0)),
    [ord_sobjid] bigint NULL DEFAULT((0)),
    [ord_authority_factor] int NULL DEFAULT((0)),
    CONSTRAINT [order_240_pk] PRIMARY KEY ([ord_id] ASC)
)

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

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

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

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

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