IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[pub_company]') AND type = 'U')
CREATE TABLE [dbo].[pub_company]
(
    [cmp_id] int NOT NULL DEFAULT((0)),
    [cmp_key] varchar(32) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_code] varchar(20) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_brief] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_fullname] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_type] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_tele] varchar(30) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_address] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_license] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_taxcode] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_master] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_mobile] varchar(20) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_www] varchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_sshy] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_qyxz] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_date] datetime NULL DEFAULT(getdate()),
    [cmp_enddate] datetime NULL DEFAULT(getdate()),
    [cmp_logwww] varchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_wwwtitle] nvarchar(200) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_loginuseri] int NULL DEFAULT((50)),
    [cmp_sqltype] varchar(20) COLLATE Chinese_PRC_CI_AS NULL DEFAULT('MSSQL'),
    [cmp_password] varchar(200) COLLATE Chinese_PRC_CI_AS NULL,
    [cmp_dbhost] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_dbprivate] varchar(20) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_dbname] varchar(20) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_goto] int NULL DEFAULT((0)),
    [cmp_pause] int NULL DEFAULT((1)),
    [cmp_pausereason] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_branch] int NULL DEFAULT((0)),
    [cmp_grouptitle] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT('总部'),
    [cmp_branchtitle] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT('分公司'),
    [cmp_groupcode] varchar(10) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_login_bg] varchar(255) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_login_title] nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_login_model] int NULL DEFAULT((0)),
    [cmp_login_picture] varchar(255) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_dbnames] varchar(1000) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_redirect] varchar(200) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_apptitle] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_baidu] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_gaode] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_google] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_language] nvarchar(200) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_dbversion] int NULL DEFAULT((0)),
    [cmp_dbupgradeserver] varchar(500) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_accountdate] datetime NULL DEFAULT(getdate()),
    [cmp_accountday] int NULL DEFAULT((0)),
    [cmp_allowemptypass] int NULL DEFAULT((0)),
    [cmp_dingid] int NULL DEFAULT((0)),
    [cmp_pubcss] nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_pubjs] nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [cmp_viewurl] nvarchar(500) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    CONSTRAINT [PK_PUB_COMPANY] PRIMARY KEY ([cmp_id] ASC)
)

IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID('[dbo].[pub_company]') AND name = 'pub_company_code_index')
CREATE UNIQUE NONCLUSTERED INDEX [pub_company_code_index] ON [dbo].[pub_company]([cmp_key] ASC)