/*==============================================================*/
/* DBMS name:      SQL Server 2005                              */
/* Created on:     2014/7/14 19:05:12                           */
/*==============================================================*/
CREATE TABLE BPM_AGENT_CONDITION (
   ID                   NUMERIC(18,0)        NOT NULL,
   SETTINGID            NUMERIC(18,0)        NULL,
   CON                  VARCHAR(1000)        NULL,
   MEMO                 VARCHAR(200)         NULL,
   AGENTID              NUMERIC(18,0)        NULL,
   AGENT                VARCHAR(100)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '条件代理的配置',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_CONDITION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_CONDITION', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程设定ID',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_CONDITION', 'column', 'SETTINGID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '条件',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_CONDITION', 'column', 'CON'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_CONDITION', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '代理人ID',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_CONDITION', 'column', 'AGENTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '代理人',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_CONDITION', 'column', 'AGENT'
go

ALTER TABLE BPM_AGENT_CONDITION
   ADD CONSTRAINT PK_BPM_AGENT_CONDITION PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_AGENT_DEF (
   ID                   NUMERIC(18,0)        NOT NULL,
   SETTINGID            NUMERIC(18,0)        NULL,
   FLOWKEY              VARCHAR(50)          NULL,
   FLOWNAME             VARCHAR(200)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '代理的流程列表',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_DEF'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_DEF', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '代理设定ID',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_DEF', 'column', 'SETTINGID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程KEY',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_DEF', 'column', 'FLOWKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程名称',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_DEF', 'column', 'FLOWNAME'
go

ALTER TABLE BPM_AGENT_DEF
   ADD CONSTRAINT PK_BPM_AGENT_DEF PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_AGENT_SETTING (
   ID                   NUMERIC(18,0)        NOT NULL,
   AUTHID               NUMERIC(18,0)        NULL,
   AUTHNAME             VARCHAR(100)         NULL,
   CREATETIME           DATETIME             NULL,
   STARTDATE            DATETIME             NULL,
   ENDDATE              DATETIME             NULL,
   ENABLED              SMALLINT             NULL,
   AUTHTYPE             SMALLINT             NULL,
   AGENTID              NUMERIC(18,0)        NULL,
   AGENT                VARCHAR(100)         NULL,
   FLOWKEY              VARCHAR(100)         NULL,
   FLOWNAME             VARCHAR(100)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '代理设定',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_SETTING'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_SETTING', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '授权人ID',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_SETTING', 'column', 'AUTHID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '授权人',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_SETTING', 'column', 'AUTHNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '授权时间',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_SETTING', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '开始时间',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_SETTING', 'column', 'STARTDATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '结束时间',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_SETTING', 'column', 'ENDDATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否启用(0,禁止,1,启用)',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_SETTING', 'column', 'ENABLED'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '授权类型(0,全权,1,部分流程,2,条件代理)',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_SETTING', 'column', 'AUTHTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '代理人ID',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_SETTING', 'column', 'AGENTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '代理人',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_SETTING', 'column', 'AGENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程key(条件代理时填写)',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_SETTING', 'column', 'FLOWKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程名称',
   'user', @CURRENTUSER, 'table', 'BPM_AGENT_SETTING', 'column', 'FLOWNAME'
go

ALTER TABLE BPM_AGENT_SETTING
   ADD CONSTRAINT PK_BPM_AGENT_SETTING PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_APPROVAL_ITEM (
   ITEMID               NUMERIC(18,0)        NOT NULL,
   USERID               NUMERIC(18,0)        NULL,
   DEFKEY               VARCHAR(128)         NULL,
   TYPEID               NUMERIC(18,0)        NULL,
   TYPE                 SMALLINT             NULL,
   EXPRESSION           VARCHAR(3000)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务审批常用语设置',
   'user', @CURRENTUSER, 'table', 'BPM_APPROVAL_ITEM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '常用语主键',
   'user', @CURRENTUSER, 'table', 'BPM_APPROVAL_ITEM', 'column', 'ITEMID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'BPM_APPROVAL_ITEM', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义Key',
   'user', @CURRENTUSER, 'table', 'BPM_APPROVAL_ITEM', 'column', 'DEFKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程分类ID',
   'user', @CURRENTUSER, 'table', 'BPM_APPROVAL_ITEM', 'column', 'TYPEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '常用语类型',
   'user', @CURRENTUSER, 'table', 'BPM_APPROVAL_ITEM', 'column', 'TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '常用语内容',
   'user', @CURRENTUSER, 'table', 'BPM_APPROVAL_ITEM', 'column', 'EXPRESSION'
go

ALTER TABLE BPM_APPROVAL_ITEM
   ADD CONSTRAINT PK_BPM_APPROVAL_ITEM PRIMARY KEY NONCLUSTERED (ITEMID)
go

CREATE TABLE BPM_BUS_LINK (
   BUS_ID               NUMERIC(18,0)        NOT NULL,
   BUS_PK               NUMERIC(18,0)        NULL,
   BUS_PKSTR            VARCHAR(50)          NULL,
   BUS_FORM_TABLE       VARCHAR(255)		 NULL,
   BUS_DEF_ID           NUMERIC(18,0)        NULL,
   BUS_FLOW_RUNID       NUMERIC(18,0)        NULL,
   BUS_CREATOR_ID       NUMERIC(18,0)        NULL,
   BUS_CREATOR          VARCHAR(50)          NULL,
   BUS_ORG_ID           NUMERIC(18,0)        NULL,
   BUS_ORG_NAME         VARCHAR(200)         NULL,
   BUS_CREATETIME       DATETIME             NULL,
   BUS_UPDID            NUMERIC(18,0)        NULL,
   BUS_UPD              VARCHAR(50)          NULL,
   BUS_STATUS 			NUMERIC(18,0)		 NULL,
   BUS_UPDTIME          DATETIME             NULL,
   BUS_PROC_INST_ID		NUMERIC(18,0)		 NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '业务数据关联表',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK', 'column', 'BUS_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '对应关联表主键',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK', 'column', 'BUS_PK'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '对应关联表名',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK', 'column', 'BUS_FORM_TABLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '对应关联表主键(字符串)',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK', 'column', 'BUS_PKSTR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK', 'column', 'BUS_DEF_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程运行ID',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK', 'column', 'BUS_FLOW_RUNID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发起人ID',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK', 'column', 'BUS_CREATOR_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发起人',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK', 'column', 'BUS_CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发起组织ID',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK', 'column', 'BUS_ORG_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织名称',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK', 'column', 'BUS_ORG_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发起时间',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK', 'column', 'BUS_CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '最后更新人',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK', 'column', 'BUS_UPDID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '最后更新人',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK', 'column', 'BUS_UPD'
go



DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '业务数据状态(0,业务数据,1,流程运行,2,流程结束,3,手工结束)',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK', 'column', 'BUS_STATUS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '最后更新时间',
   'user', @CURRENTUSER, 'table', 'BPM_BUS_LINK', 'column', 'BUS_UPDTIME'
go

ALTER TABLE BPM_BUS_LINK
   ADD CONSTRAINT PK_BPM_BUS_LINK PRIMARY KEY NONCLUSTERED (BUS_ID)
go

CREATE TABLE BPM_COMMON_WS_PARAMS (
   ID                   NUMERIC(18,0)        NOT NULL,
   SETID                NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(200)         NULL,
   PARAM_TYPE           INT                  NULL,
   DESCRIPTION          VARCHAR(400)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '通用webservice调用参数',
   'user', @CURRENTUSER, 'table', 'BPM_COMMON_WS_PARAMS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_COMMON_WS_PARAMS', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'webservice设置ID',
   'user', @CURRENTUSER, 'table', 'BPM_COMMON_WS_PARAMS', 'column', 'SETID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '参数名',
   'user', @CURRENTUSER, 'table', 'BPM_COMMON_WS_PARAMS', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '参数类型',
   'user', @CURRENTUSER, 'table', 'BPM_COMMON_WS_PARAMS', 'column', 'PARAM_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '参数说明',
   'user', @CURRENTUSER, 'table', 'BPM_COMMON_WS_PARAMS', 'column', 'DESCRIPTION'
go

ALTER TABLE BPM_COMMON_WS_PARAMS
   ADD CONSTRAINT PK_BPM_COMMON_WS_PARAMS PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_COMMON_WS_SET (
   ID                   NUMERIC(18,0)        NOT NULL,
   ALIAS                VARCHAR(200)         NOT NULL,
   WSDL_URL             VARCHAR(400)         NULL,
   DOCUMENT             TEXT                 NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '通用WEBSERVICE调用设置',
   'user', @CURRENTUSER, 'table', 'BPM_COMMON_WS_SET'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_COMMON_WS_SET', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '别名',
   'user', @CURRENTUSER, 'table', 'BPM_COMMON_WS_SET', 'column', 'ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'wsdl地址',
   'user', @CURRENTUSER, 'table', 'BPM_COMMON_WS_SET', 'column', 'WSDL_URL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '通用webservice调用参数列表',
   'user', @CURRENTUSER, 'table', 'BPM_COMMON_WS_SET', 'column', 'DOCUMENT'
go

ALTER TABLE BPM_COMMON_WS_SET
   ADD CONSTRAINT PK_BPM_COMMON_WS_SET PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_COMMU_RECEIVER (
   ID                   NUMERIC(18,0)        NOT NULL,
   OPINIONID            NUMERIC(18,0)        NULL,
   RECEVIERID           NUMERIC(18,0)        NULL,
   RECEIVERNAME         VARCHAR(100)         NULL,
   STATUS               SMALLINT             NULL,
   RECEIVETIME          DATETIME             NULL,
   CREATETIME           DATETIME             NULL,
   FEEDBACKTIME         DATETIME             NULL,
   TASKID               NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '沟通接收人',
   'user', @CURRENTUSER, 'table', 'BPM_COMMU_RECEIVER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_COMMU_RECEIVER', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '意见ID',
   'user', @CURRENTUSER, 'table', 'BPM_COMMU_RECEIVER', 'column', 'OPINIONID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '接收人ID',
   'user', @CURRENTUSER, 'table', 'BPM_COMMU_RECEIVER', 'column', 'RECEVIERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '接收人',
   'user', @CURRENTUSER, 'table', 'BPM_COMMU_RECEIVER', 'column', 'RECEIVERNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '状态',
   'user', @CURRENTUSER, 'table', 'BPM_COMMU_RECEIVER', 'column', 'STATUS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '接收时间',
   'user', @CURRENTUSER, 'table', 'BPM_COMMU_RECEIVER', 'column', 'RECEIVETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'BPM_COMMU_RECEIVER', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '反馈时间',
   'user', @CURRENTUSER, 'table', 'BPM_COMMU_RECEIVER', 'column', 'FEEDBACKTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务ID',
   'user', @CURRENTUSER, 'table', 'BPM_COMMU_RECEIVER', 'column', 'TASKID'
go

ALTER TABLE BPM_COMMU_RECEIVER
   ADD CONSTRAINT PK_BPM_COMMU_RECEIVER PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_DATA_TEMPLATE (
   ID                   NUMERIC(18,0)        NOT NULL,
   TABLEID              NUMERIC(18,0)        NULL,
   FORMKEY              VARCHAR(50)          NULL,
   NAME                 VARCHAR(300)         NULL,
   ALIAS                VARCHAR(50)          NULL,
   STYLE                SMALLINT             NULL DEFAULT 0,
   NEEDPAGE             SMALLINT             NULL DEFAULT 1,
   PAGESIZE             SMALLINT             NULL,
   TEMPLATEALIAS        VARCHAR(50)          NULL,
   TEMPLATEHTML         TEXT                 NULL,
   DISPLAYFIELD         TEXT                 NULL,
   SORTFIELD            VARCHAR(200)         NULL,
   CONDITIONFIELD       TEXT        NULL,
   MANAGEFIELD          VARCHAR(2000)       NULL,
   FILTERFIELD          TEXT                 NULL,
   VARFIELD             VARCHAR(200)                 NULL,
   FILTERTYPE           SMALLINT             NULL DEFAULT 1,
   SOURCE               SMALLINT             NULL DEFAULT 1,
   DEFID                NUMERIC(18,0)        NULL,
   ISQUERY              SMALLINT             NULL DEFAULT 1,
   ISFILTER             INT                  NULL DEFAULT 1,
   PRINTFIELD           TEXT                 NULL,
   EXPORTFIELD          TEXT                 NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '业务数据模板',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '自定义表ID',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'TABLEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '自定义表单key',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'FORMKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '名称',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '别名',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '样式',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'STYLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否需要分页',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'NEEDPAGE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分页大小',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'PAGESIZE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据模板别名',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'TEMPLATEALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据模板代码',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'TEMPLATEHTML'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '显示字段',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'DISPLAYFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序字段',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'SORTFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '条件字段',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'CONDITIONFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '管理字段',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'MANAGEFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '过滤条件',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'FILTERFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '变量字段',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'VARFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '过滤类型（1.建立条件,2.脚本条件）',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'FILTERTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据来源',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'SOURCE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'DEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否查询',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'ISQUERY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否过滤',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'ISFILTER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '打印字段',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'PRINTFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '导出字段',
   'user', @CURRENTUSER, 'table', 'BPM_DATA_TEMPLATE', 'column', 'EXPORTFIELD'
go

ALTER TABLE BPM_DATA_TEMPLATE
   ADD CONSTRAINT PK_BPM_DATA_TEMPLATE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_DEFINITION (
   DEFID                NUMERIC(18,0)        NOT NULL,
   TYPEID               NUMERIC(18,0)        NULL,
   SUBJECT              VARCHAR(256)         NOT NULL,
   DEFKEY               VARCHAR(128)         NOT NULL,
   TASKNAMERULE         VARCHAR(512)         NULL,
   DESCP                VARCHAR(1024)        NULL,
   STATUS               SMALLINT             NULL,
   DEFXML               TEXT                 NULL,
   ACTDEPLOYID          NUMERIC(18,0)        NULL,
   ACTDEFKEY            VARCHAR(255)         NULL,
   ACTDEFID             VARCHAR(128)         NULL,
   CREATETIME           DATETIME             NULL,
   UPDATETIME           DATETIME             NULL,
   CREATEBY             NUMERIC(18,0)        NULL,
   UPDATEBY             NUMERIC(18,0)        NULL,
   REASON               VARCHAR(512)         NULL,
   VERSIONNO            NUMERIC(18,0)        NULL,
   PARENTDEFID          NUMERIC(18,0)        NULL,
   ISMAIN               SMALLINT             NULL,
   TOFIRSTNODE          NUMERIC(18,0)        NULL,
   SHOWFIRSTASSIGNEE    SMALLINT             NULL,
   CANCHOICEPATH        VARCHAR(500)         NULL,
   ISUSEOUTFORM         SMALLINT             NULL,
   FORMDETAILURL        VARCHAR(200)         NULL,
   ALLOWFINISHEDCC      SMALLINT             NULL,
   SUBMITCONFIRM        SMALLINT             NULL,
   ALLOWDIVERT          SMALLINT             NULL,
   INFORMSTART          VARCHAR(20)          NULL,
   INFORMTYPE           VARCHAR(20)          NULL,
   ATTACHMENT           NUMERIC(18,0)        NULL,
   SAMEEXECUTORJUMP     SMALLINT             NULL,
   ALLOWREFER           SMALLINT             NULL,
   INSTANCEAMOUNT       SMALLINT             NULL,
   ALLOWFINISHEDDIVERT  SMALLINT             NULL,
   ISPRINTFORM          SMALLINT             NULL,
   DIRECTSTART          SMALLINT             NULL,
   CCMESSAGETYPE        VARCHAR(100)         NULL,
   ALLOWDELDRAF         SMALLINT             NULL,
   TESTSTATUSTAG        VARCHAR(100)         NULL,
   ALLOWMOBILE          INT                  NULL DEFAULT 1,
   SKIPSETTING          VARCHAR(50)          NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义扩展
   Code:DEFTN',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'DEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分类ID',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'TYPEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程标题',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'SUBJECT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义Key
   流程定义Key，由设计人员加上，唯一',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'DEFKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务标题生成规则',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'TASKNAMERULE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程描述',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'DESCP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程状态
   0=草稿
   1=发布
   2=挂起
   ',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'STATUS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义XML(设计器)',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'DEFXML'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'activiti流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'ACTDEPLOYID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'act流程定义Key
   act流程定义Key，其生成的规则为流程定义Key+动态生成值，保证其唯一，当流程定义删除时，本表记录会删除，但actiiti的流程定义的数据则不删除，这样发布的流程会跟原来的流程定义的key可能会同样，因此，后续再加动态值，保证其值会activit的流程定义中key也唯一.',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'ACTDEFKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'act流程定义',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '更新时间',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'UPDATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'CREATEBY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '更新人',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'UPDATEBY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '变更原因',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'REASON'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '版本号',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'VERSIONNO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '隶属主定义ID
   
   当基于旧版本流程上进行新版本发布时，则生成一份新的记录，并且该记录的该字段则隶属于原来记录的主键id',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'PARENTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否为主版本
   1=主版本
   0=非主版本
   ',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'ISMAIN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '跳转到第一个节点
   0,不跳转
   1,跳转',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'TOFIRSTNODE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否可以选择执行人',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'SHOWFIRSTASSIGNEE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否可以选择条件同步路径',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'CANCHOICEPATH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否允许API调用',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'ISUSEOUTFORM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '明细URL',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'FORMDETAILURL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否允许流程结束时抄送',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'ALLOWFINISHEDCC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '提交是否需要确认',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'SUBMITCONFIRM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否允许转办',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'ALLOWDIVERT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '归档时发送消息给发起人 类型',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'INFORMSTART'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '通知类型',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'INFORMTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '帮助附件',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'ATTACHMENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '相同任务节点是否允许跳转',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'SAMEEXECUTORJUMP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '允许参考数',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'ALLOWREFER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '允许实例数量',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'INSTANCEAMOUNT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否允许我的办结转发',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'ALLOWFINISHEDDIVERT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否开启打印模版功能',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'ISPRINTFORM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '直接启动不需要使用表单',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'DIRECTSTART'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '抄送消息类型 ',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'CCMESSAGETYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '测试状态',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'TESTSTATUSTAG'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   ' 0=不支持，1=支持',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'ALLOWMOBILE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '跳过设置',
   'user', @CURRENTUSER, 'table', 'BPM_DEFINITION', 'column', 'SKIPSETTING'
go

ALTER TABLE BPM_DEFINITION
   ADD CONSTRAINT PK_BPM_DEFINITION PRIMARY KEY NONCLUSTERED (DEFID)
go

CREATE TABLE BPM_DEF_ACT (
   ID                   NUMERIC(18,0)        NOT NULL,
   AUTHORIZE_ID         NUMERIC(18,0)        NOT NULL,
   DEF_KEY              VARCHAR(100)         NOT NULL,
   DEF_NAME             VARCHAR(200)         NULL,
   RIGHT_CONTENT        VARCHAR(400)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程授权主表明细 ',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_ACT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_ACT', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程分管权限主表ID',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_ACT', 'column', 'AUTHORIZE_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程KEY',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_ACT', 'column', 'DEF_KEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程名称',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_ACT', 'column', 'DEF_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程权限内容',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_ACT', 'column', 'RIGHT_CONTENT'
go

ALTER TABLE BPM_DEF_ACT
   ADD CONSTRAINT PK_BPM_DEF_ACT PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_DEF_AUTHORIZE (
   ID                   NUMERIC(18,0)        NOT NULL,
   AUTHORIZE_DESC       VARCHAR(512)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程授权主表明细',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_AUTHORIZE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_AUTHORIZE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程授权说明',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_AUTHORIZE', 'column', 'AUTHORIZE_DESC'
go

ALTER TABLE BPM_DEF_AUTHORIZE
   ADD CONSTRAINT PK_BPM_DEF_AUTHORIZE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_DEF_USER (
   ID                   NUMERIC(18,0)        NOT NULL,
   AUTHORIZE_ID         NUMERIC(18,0)        NOT NULL,
   OWNER_ID             NUMERIC(18,0)        NOT NULL,
   OWNER_NAME           VARCHAR(200)         NULL,
   RIGHT_TYPE           VARCHAR(200)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程授权主表',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_USER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_USER', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程分管权限主表ID',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_USER', 'column', 'AUTHORIZE_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '权限所有者ID',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_USER', 'column', 'OWNER_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '权限所有者',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_USER', 'column', 'OWNER_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '权限类型',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_USER', 'column', 'RIGHT_TYPE'
go

ALTER TABLE BPM_DEF_USER
   ADD CONSTRAINT PK_BPM_DEF_USER PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_DEF_VARS (
   VARID                NUMERIC(18,0)        NOT NULL,
   DEFID                NUMERIC(18,0)        NULL,
   VARNAME              VARCHAR(128)         NOT NULL,
   VARKEY               VARCHAR(128)         NULL,
   VARDATATYPE          VARCHAR(64)          NULL,
   DEFVALUE             VARCHAR(256)         NULL,
   NODENAME             VARCHAR(256)         NULL,
   NODEID               VARCHAR(256)         NULL,
   ACTDEPLOYID          NUMERIC(18,0)        NULL,
   VARSCOPE             VARCHAR(64)          NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程变量定义',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_VARS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '变量ID',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_VARS', 'column', 'VARID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_VARS', 'column', 'DEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '变量名称',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_VARS', 'column', 'VARNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '变量Key',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_VARS', 'column', 'VARKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '变量数据类型
   
   string
   date
   number',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_VARS', 'column', 'VARDATATYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '默认值',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_VARS', 'column', 'DEFVALUE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点名称',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_VARS', 'column', 'NODENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_VARS', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'actDeployId',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_VARS', 'column', 'ACTDEPLOYID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '作用域
   
   全局内=global
   任务内=task',
   'user', @CURRENTUSER, 'table', 'BPM_DEF_VARS', 'column', 'VARSCOPE'
go

ALTER TABLE BPM_DEF_VARS
   ADD CONSTRAINT PK_BPM_DEF_VARS PRIMARY KEY NONCLUSTERED (VARID)
go

CREATE TABLE BPM_EXE_STACK (
   STACKID              NUMERIC(18,0)        NOT NULL,
   ACTDEFID             VARCHAR(64)          NULL,
   NODEID               VARCHAR(128)         NOT NULL,
   NODENAME             VARCHAR(256)         NULL,
   STARTTIME            DATETIME             NULL,
   ENDTIME              DATETIME             NULL,
   ASSIGNEES            VARCHAR(1024)        NULL,
   ISMULTITASK          SMALLINT             NULL,
   PARENTID             NUMERIC(18,0)        NULL,
   ACTINSTID            NUMERIC(18,0)        NULL,
   TASKIDS              VARCHAR(512)         NULL,
   NODEPATH             VARCHAR(1024)        NULL,
   DEPTH                NUMERIC(18,0)        NULL,
   TASKTOKEN            VARCHAR(128)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程执行堆栈树',
   'user', @CURRENTUSER, 'table', 'BPM_EXE_STACK'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_EXE_STACK', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_EXE_STACK', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点名',
   'user', @CURRENTUSER, 'table', 'BPM_EXE_STACK', 'column', 'NODENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '开始时间',
   'user', @CURRENTUSER, 'table', 'BPM_EXE_STACK', 'column', 'STARTTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '结束时间',
   'user', @CURRENTUSER, 'table', 'BPM_EXE_STACK', 'column', 'ENDTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '执行人IDS，如1,2,3',
   'user', @CURRENTUSER, 'table', 'BPM_EXE_STACK', 'column', 'ASSIGNEES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '1=是
   0=否',
   'user', @CURRENTUSER, 'table', 'BPM_EXE_STACK', 'column', 'ISMULTITASK'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '父ID',
   'user', @CURRENTUSER, 'table', 'BPM_EXE_STACK', 'column', 'PARENTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_EXE_STACK', 'column', 'ACTINSTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务IDS',
   'user', @CURRENTUSER, 'table', 'BPM_EXE_STACK', 'column', 'TASKIDS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点路径
   格式如：
   0.1.2.
   其中2则为本行记录的主键值',
   'user', @CURRENTUSER, 'table', 'BPM_EXE_STACK', 'column', 'NODEPATH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点层',
   'user', @CURRENTUSER, 'table', 'BPM_EXE_STACK', 'column', 'DEPTH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是针对分发任务时，携带的令牌，方便查找其父任务堆栈',
   'user', @CURRENTUSER, 'table', 'BPM_EXE_STACK', 'column', 'TASKTOKEN'
go

ALTER TABLE BPM_EXE_STACK
   ADD CONSTRAINT PK_BPM_EXE_STACK PRIMARY KEY NONCLUSTERED (STACKID)
go

CREATE TABLE BPM_FORM_DEF (
   FORMDEFID            NUMERIC(18,0)        NOT NULL,
   CATEGORYID           NUMERIC(18,0)        NULL,
   FORMKEY              VARCHAR(128)         NULL,
   SUBJECT              VARCHAR(128)         NULL,
   FORMDESC             VARCHAR(200)         NULL,
   HTML                 TEXT                 NULL,
   TEMPLATE             TEXT                 NULL,
   ISDEFAULT            SMALLINT             NULL,
   VERSIONNO            NUMERIC(18,0)        NULL,
   TABLEID              NUMERIC(18,0)        NULL,
   ISPUBLISHED          SMALLINT             NULL,
   PUBLISHEDBY          VARCHAR(20)          NULL,
   PUBLISHTIME          DATETIME             NULL,
   TABTITLE             VARCHAR(500)         NULL,
   DESIGNTYPE           SMALLINT             NULL,
   TEMPLATESID          VARCHAR(300)         NULL,
   CREATEBY             NUMERIC(18,0)        NULL,
   CREATOR              VARCHAR(50)          NULL,
   CREATETIME           DATETIME             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程表单定义',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单ID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'FORMDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单分类',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'CATEGORYID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单key',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'FORMKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单标题',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'SUBJECT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '描述',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'FORMDESC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '定义html',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'HTML'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'freeMaker模版',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'TEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否缺省',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'ISDEFAULT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '版本号',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'VERSIONNO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表ID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'TABLEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否发布',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'ISPUBLISHED'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发布人',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'PUBLISHEDBY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发布时间',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'PUBLISHTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'Tab标题',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'TABTITLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '设计类型',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'DESIGNTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模板表对应ID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'TEMPLATESID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人ID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'CREATEBY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DEF', 'column', 'CREATETIME'
go

ALTER TABLE BPM_FORM_DEF
   ADD CONSTRAINT PK_BPM_FORM_DEF PRIMARY KEY NONCLUSTERED (FORMDEFID)
go

CREATE TABLE BPM_FORM_DIALOG (
   ID                   NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(50)          NULL,
   ALIAS                VARCHAR(50)          NULL,
   STYLE                SMALLINT             NULL,
   WIDTH                NUMERIC(18,0)        NULL,
   HEIGHT               NUMERIC(18,0)        NULL,
   ISSINGLE             SMALLINT             NULL,
   NEEDPAGE             SMALLINT             NULL,
   ISTABLE              SMALLINT             NULL,
   OBJNAME              VARCHAR(50)          NULL,
   DISPLAYFIELD         VARCHAR(2000)        NULL,
   CONDITIONFIELD       VARCHAR(2000)        NULL,
   RESULTFIELD          VARCHAR(1000)        NULL,
   DSNAME               VARCHAR(50)          NULL,
   DSALIAS              VARCHAR(50)          NULL,
   PAGESIZE             SMALLINT             NULL,
   SORTFIELD            VARCHAR(200)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '通用表单对话框
   ',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键ID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '对话框名称',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '对话框别名
   唯一',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '显示样式
   0,列表
   1,树形',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'STYLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '对话框宽度',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'WIDTH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '高度',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'HEIGHT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否单选
   0,多选
   1.单选',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'ISSINGLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否分页',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'NEEDPAGE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否为表
   0,视图
   1,数据库表',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'ISTABLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '对象名称',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'OBJNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '需要显示的字段',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'DISPLAYFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '条件字段',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'CONDITIONFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '显示结果字段',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'RESULTFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据源名称',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'DSNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据源别名',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'DSALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分页大小',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'PAGESIZE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序字段',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_DIALOG', 'column', 'SORTFIELD'
go

ALTER TABLE BPM_FORM_DIALOG
   ADD CONSTRAINT PK_BPM_FORM_DIALOG PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_FORM_FIELD (
   FIELDID              NUMERIC(18,0)        NOT NULL,
   TABLEID              NUMERIC(18,0)        NULL,
   FIELDNAME            VARCHAR(128)         NOT NULL,
   FIELDTYPE            VARCHAR(128)         NOT NULL,
   ISREQUIRED           SMALLINT             NULL,
   ISLIST               SMALLINT             NULL DEFAULT 1,
   ISQUERY              SMALLINT             NULL DEFAULT 1,
   FIELDDESC            VARCHAR(128)         NULL,
   CHARLEN              NUMERIC(18,0)        NULL,
   INTLEN               NUMERIC(18,0)        NULL,
   DECIMALLEN           NUMERIC(18,0)        NULL,
   DICTTYPE             VARCHAR(100)         NULL,
   ISDELETED            SMALLINT             NULL,
   VALIDRULE            VARCHAR(64)          NULL,
   ORIGINALNAME         VARCHAR(128)         NULL,
   SN                   NUMERIC(18,0)        NULL,
   VALUEFROM            SMALLINT             NULL,
   SCRIPT               VARCHAR(1000)        NULL,
   CONTROLTYPE          SMALLINT             NULL,
   ISHIDDEN             SMALLINT             NULL,
   ISFLOWVAR            SMALLINT             NULL,
   SERIALNUM            VARCHAR(20)          NULL,
   OPTIONS              VARCHAR(1000)        NULL,
   CTLPROPERTY          VARCHAR(2000)        NULL,
   ISALLOWMOBILE        SMALLINT             NULL,
   ISWEBSIGN            SMALLINT             NULL,
   ISREFERENCE          SMALLINT             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单字段',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '字段名称',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'FIELDNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '字段类型',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'FIELDTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否必填',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'ISREQUIRED'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否列表显示',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'ISLIST'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否查询显示',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'ISQUERY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否必填',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'FIELDDESC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '字符长度',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'CHARLEN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '整数长度',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'INTLEN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '小数长度',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'DECIMALLEN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据字典类别',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'DICTTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否删除',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'ISDELETED'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '验证规则',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'VALIDRULE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '字段原名',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'ORIGINALNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排列顺序',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'SN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '值来源
   0 - 表单
   1 - 脚本',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'VALUEFROM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '默认脚本',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'SCRIPT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '0,无特殊控件
   1,数据字典
   2,用户选择器
   3.组织选择器',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'CONTROLTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否隐藏域',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'ISHIDDEN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否流程变量',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'ISFLOWVAR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流水号别名',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'SERIALNUM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '选项',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'OPTIONS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '控件属性',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'CTLPROPERTY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否支持手机客户端访问',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'ISALLOWMOBILE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否需要签名',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'ISWEBSIGN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否流程引用',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_FIELD', 'column', 'ISREFERENCE'
go

ALTER TABLE BPM_FORM_FIELD
   ADD CONSTRAINT PK_BPM_FORM_FIELD PRIMARY KEY NONCLUSTERED (FIELDID)
go

CREATE TABLE BPM_FORM_QUERY (
   ID                   NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(50)          NULL,
   ALIAS                VARCHAR(50)          NULL,
   OBJ_NAME             VARCHAR(50)          NULL,
   NEEDPAGE             NUMERIC(18,0)        NULL,
   CONDITIONFIELD       VARCHAR(2000)        NULL,
   RESULTFIELD          VARCHAR(2000)        NULL,
   DSNAME               VARCHAR(50)          NULL,
   DSALIAS              VARCHAR(50)          NULL,
   PAGESIZE             NUMERIC(18,0)        NULL DEFAULT 10,
   ISTABLE              NUMERIC(18,0)        NULL,
   SORTFIELD            VARCHAR(200)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '通用表单查询',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_QUERY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_QUERY', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '名称',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_QUERY', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '别名',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_QUERY', 'column', 'ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '查询对象名称',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_QUERY', 'column', 'OBJ_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否分页 0：否，1：是',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_QUERY', 'column', 'NEEDPAGE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '条件字段',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_QUERY', 'column', 'CONDITIONFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '返回字段',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_QUERY', 'column', 'RESULTFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据源名称',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_QUERY', 'column', 'DSNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据源别名',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_QUERY', 'column', 'DSALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分页条数',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_QUERY', 'column', 'PAGESIZE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否为表
   0,视图
   1,数据库表',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_QUERY', 'column', 'ISTABLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序字段',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_QUERY', 'column', 'SORTFIELD'
go

ALTER TABLE BPM_FORM_QUERY
   ADD CONSTRAINT PK_BPM_FORM_QUERY PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_FORM_RIGHTS (
   ID                   NUMERIC(18,0)        NOT NULL,
   FORMKEY              VARCHAR(50)          NULL,
   NAME                 VARCHAR(128)         NULL,
   PERMISSION           VARCHAR(2000)        NULL,
   TYPE                 SMALLINT             NULL,
   NODEID               VARCHAR(60)          NULL,
   ACTDEFID             VARCHAR(60)          NULL,
   PARENTACTDEFID       VARCHAR(128)         NULL,
   PLATFORM             INT                  NULL DEFAULT 1
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单权限
   ',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RIGHTS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RIGHTS', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单ID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RIGHTS', 'column', 'FORMKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '字段名',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RIGHTS', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '权限',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RIGHTS', 'column', 'PERMISSION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '权限类型(1,字段,2,子表,3,意见)',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RIGHTS', 'column', 'TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RIGHTS', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'ACTDEFID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RIGHTS', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '父类流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RIGHTS', 'column', 'PARENTACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '0表示pc，1表示mobile',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RIGHTS', 'column', 'PLATFORM'
go

ALTER TABLE BPM_FORM_RIGHTS
   ADD CONSTRAINT PK_BPM_FORM_RIGHTS PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_FORM_RULE (
   ID                   NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(50)          NULL,
   REGULATION           VARCHAR(100)         NULL,
   MEMO                 VARCHAR(100)         NULL,
   TIPINFO              VARCHAR(100)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单认证规则',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RULE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RULE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '规则名',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RULE', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '规则',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RULE', 'column', 'REGULATION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RULE', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '提示信息',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RULE', 'column', 'TIPINFO'
go

ALTER TABLE BPM_FORM_RULE
   ADD CONSTRAINT PK_BPM_FORM_RULE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_FORM_RUN (
   ID                   NUMERIC(18,0)        NOT NULL,
   FORMDEFID            NUMERIC(18,0)        NULL,
   FORMDEFKEY           VARCHAR(50)        NULL,
   ACTINSTANCEID        VARCHAR(64)          NULL,
   ACTDEFID             VARCHAR(64)          NULL,
   ACTNODEID            VARCHAR(64)          NULL,
   RUNID                NUMERIC(18,0)        NULL,
   SETTYPE              SMALLINT             NULL,
   FORMTYPE             SMALLINT             NULL,
   FORMURL              VARCHAR(255)         NULL,
   MOBILEFORMID         NUMERIC(18)          NULL,
   MOBILEFORMKEY        VARCHAR(50)          NULL,
   MOBILEFORMURL        VARCHAR(255)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程表单运行情况',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RUN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RUN', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RUN', 'column', 'FORMDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单定义key',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RUN', 'column', 'FORMDEFKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RUN', 'column', 'ACTINSTANCEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RUN', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程节点id',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RUN', 'column', 'ACTNODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程运行ID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RUN', 'column', 'RUNID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单类型
   0,任务节点
   1,开始表单
   2,全局表单',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RUN', 'column', 'SETTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单类型',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RUN', 'column', 'FORMTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单地址',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RUN', 'column', 'FORMURL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '手机表单ID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RUN', 'column', 'MOBILEFORMID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '手机表单KEY',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RUN', 'column', 'MOBILEFORMKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '手机表单URL',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_RUN', 'column', 'MOBILEFORMURL'
go

ALTER TABLE BPM_FORM_RUN
   ADD CONSTRAINT PK_BPM_FORM_RUN PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_FORM_TABLE (
   TABLEID              NUMERIC(18,0)        NOT NULL,
   TABLENAME            VARCHAR(128)         NOT NULL,
   TABLEDESC            VARCHAR(128)         NULL,
   ISMAIN               SMALLINT             NULL,
   MAINTABLEID          NUMERIC(18,0)        NULL,
   ISPUBLISHED          SMALLINT             NULL,
   PUBLISHEDBY          VARCHAR(100)         NULL,
   PUBLISHTIME          DATETIME             NULL,
   ISEXTERNAL           SMALLINT             NULL,
   DSALIAS              VARCHAR(50)          NULL,
   DSNAME               VARCHAR(50)          NULL,
   RELATION             VARCHAR(500)         NULL,
   KEYTYPE              SMALLINT             NULL,
   KEYVALUE             VARCHAR(20)          NULL,
   PKFIELD              VARCHAR(20)          NULL,
   LISTTEMPLATE         TEXT                 NULL,
   DETAILTEMPLATE       TEXT                 NULL,
   GENBYFORM            SMALLINT             NULL,
   CREATETIME           DATETIME             NULL,
   CREATOR              VARCHAR(50)          NULL,
   CREATEBY             NUMERIC(18,0)        NULL,
   KEYDATATYPE          SMALLINT             NULL,
   TEAM                 TEXT                 NULL,
   CATEGORYID           NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单数据库表',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表名',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'TABLENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '描述',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'TABLEDESC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否主表',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'ISMAIN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '所属主表',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'MAINTABLEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否已发布',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'ISPUBLISHED'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发布人',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'PUBLISHEDBY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发布时间',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'PUBLISHTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否外部数据源',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'ISEXTERNAL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据源别名',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'DSALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据源名称',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'DSNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '字段关联关系',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'RELATION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '键类型',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'KEYTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '键值',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'KEYVALUE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键字段',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'PKFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '列表模板',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'LISTTEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '明细模板',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'DETAILTEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否同表单生成',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'GENBYFORM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人ID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人ID',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'CREATEBY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键数据类型(0,数字,1字符串)',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'KEYDATATYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分组',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TABLE', 'column', 'TEAM'
go

ALTER TABLE BPM_FORM_TABLE
   ADD CONSTRAINT PK_BPM_FORM_TABLE PRIMARY KEY NONCLUSTERED (TABLEID)
go

CREATE TABLE BPM_FORM_TEMPLATE (
   TEMPLATEID           NUMERIC(18,0)        NOT NULL,
   TEMPLATENAME         VARCHAR(200)         NULL,
   TEMPLATETYPE         VARCHAR(20)          NULL,
   MACROTEMPLATEALIAS   VARCHAR(50)          NULL,
   HTML                 TEXT                 NULL,
   TEMPLATEDESC         VARCHAR(400)         NULL,
   CANEDIT              SMALLINT             NULL,
   ALIAS                VARCHAR(50)          NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单模版',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版名称',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TEMPLATE', 'column', 'TEMPLATENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版类型',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TEMPLATE', 'column', 'TEMPLATETYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '使用宏模板别名',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TEMPLATE', 'column', 'MACROTEMPLATEALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版代码',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TEMPLATE', 'column', 'HTML'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版描述',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TEMPLATE', 'column', 'TEMPLATEDESC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '能否编辑',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TEMPLATE', 'column', 'CANEDIT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '别名',
   'user', @CURRENTUSER, 'table', 'BPM_FORM_TEMPLATE', 'column', 'ALIAS'
go

ALTER TABLE BPM_FORM_TEMPLATE
   ADD CONSTRAINT PK_BPM_FORM_TEMPLATE PRIMARY KEY NONCLUSTERED (TEMPLATEID)
go

CREATE TABLE BPM_GANGED_SET (
   ID                   NUMERIC(18,0)        NOT NULL,
   DEFID                NUMERIC(18,0)        NULL,
   NODEID               VARCHAR(100)         NULL,
   NODENAME             VARCHAR(200)         NULL,
   CHOISEFIELD          TEXT                 NULL,
   CHANGEFIELD          TEXT                 NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单联动设置',
   'user', @CURRENTUSER, 'table', 'BPM_GANGED_SET'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_GANGED_SET', 'column', 'DEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_GANGED_SET', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点名称',
   'user', @CURRENTUSER, 'table', 'BPM_GANGED_SET', 'column', 'NODENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '选择框字段设置',
   'user', @CURRENTUSER, 'table', 'BPM_GANGED_SET', 'column', 'CHOISEFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '变更字段设置',
   'user', @CURRENTUSER, 'table', 'BPM_GANGED_SET', 'column', 'CHANGEFIELD'
go

ALTER TABLE BPM_GANGED_SET
   ADD CONSTRAINT PK_BPM_GANGED_SET PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_MOBILE_FORM (
   ID                   NUMERIC(18)          NOT NULL,
   FORMID               NUMERIC(18)          NULL,
   FORMKEY              VARCHAR(64)          NULL,
   HTML                 TEXT                 NULL,
   TEMPLATE             TEXT                 NULL,
   GUID                 VARCHAR(128)         NULL,
   ISDEFAULT            INT                  NULL,
   FORMJSON             TEXT                 NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '手机表单设置',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单主键',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM', 'column', 'FORMID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单key',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM', 'column', 'FORMKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'html',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM', 'column', 'HTML'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模板',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM', 'column', 'TEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'GUID',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM', 'column', 'GUID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否默认',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM', 'column', 'ISDEFAULT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '字段列表',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM', 'column', 'FORMJSON'
go

ALTER TABLE BPM_MOBILE_FORM
   ADD CONSTRAINT PK_BPM_MOBILE_FORM PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_MON_GROUP (
   ID                   NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(200)         NULL,
   GRADE                SMALLINT             NULL,
   ENABLED              SMALLINT             NULL,
   CREATORID            NUMERIC(18,0)        NULL,
   CREATOR              VARCHAR(50)          NULL,
   CREATETIME           DATETIME             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程监控分组',
   'user', @CURRENTUSER, 'table', 'BPM_MON_GROUP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_MON_GROUP', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分组名',
   'user', @CURRENTUSER, 'table', 'BPM_MON_GROUP', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '权限等级',
   'user', @CURRENTUSER, 'table', 'BPM_MON_GROUP', 'column', 'GRADE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否生效',
   'user', @CURRENTUSER, 'table', 'BPM_MON_GROUP', 'column', 'ENABLED'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人ID',
   'user', @CURRENTUSER, 'table', 'BPM_MON_GROUP', 'column', 'CREATORID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'BPM_MON_GROUP', 'column', 'CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'BPM_MON_GROUP', 'column', 'CREATETIME'
go

ALTER TABLE BPM_MON_GROUP
   ADD CONSTRAINT PK_BPM_MON_GROUP PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_MON_GROUPITEM (
   ID                   NUMERIC(18,0)        NOT NULL,
   GROUPID              NUMERIC(18,0)        NULL,
   FLOWKEY              VARCHAR(50)          NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分组流程定义',
   'user', @CURRENTUSER, 'table', 'BPM_MON_GROUPITEM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分组ID',
   'user', @CURRENTUSER, 'table', 'BPM_MON_GROUPITEM', 'column', 'GROUPID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义KEY',
   'user', @CURRENTUSER, 'table', 'BPM_MON_GROUPITEM', 'column', 'FLOWKEY'
go

ALTER TABLE BPM_MON_GROUPITEM
   ADD CONSTRAINT PK_BPM_MON_GROUPITEM PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_MON_ORGROLE (
   ID                   NUMERIC(18,0)        NOT NULL,
   GROUPID              NUMERIC(18,0)        NULL,
   ROLEID               NUMERIC(18,0)        NULL,
   ORGID                NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分组角色组织授权',
   'user', @CURRENTUSER, 'table', 'BPM_MON_ORGROLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_MON_ORGROLE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分组ID',
   'user', @CURRENTUSER, 'table', 'BPM_MON_ORGROLE', 'column', 'GROUPID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '角色ID',
   'user', @CURRENTUSER, 'table', 'BPM_MON_ORGROLE', 'column', 'ROLEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织ID',
   'user', @CURRENTUSER, 'table', 'BPM_MON_ORGROLE', 'column', 'ORGID'
go

ALTER TABLE BPM_MON_ORGROLE
   ADD CONSTRAINT PK_BPM_MON_ORGROLE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_NODE_BTN (
   ID                   NUMERIC(18,0)        NOT NULL,
   ACTDEFID             VARCHAR(64)          NULL,
   ISSTARTFORM          SMALLINT             NULL,
   NODEID               VARCHAR(50)          NULL,
   BTNNAME              VARCHAR(50)          NULL,
   ICONCLSNAME          VARCHAR(50)          NULL,
   OPERATORTYPE         SMALLINT             NULL,
   PREVSCRIPT           VARCHAR(2000)        NULL,
   AFTERSCRIPT          VARCHAR(2000)        NULL,
   NODETYPE             SMALLINT             NULL,
   SN                   NUMERIC(18,0)        NULL,
   DEFID                NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '自定义工具条',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_BTN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_BTN', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_BTN', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程启动表单
   0,启动表单
   1,任务表单',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_BTN', 'column', 'ISSTARTFORM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_BTN', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '按钮名称',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_BTN', 'column', 'BTNNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '图标样式',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_BTN', 'column', 'ICONCLSNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '操作类型',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_BTN', 'column', 'OPERATORTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '前置脚本',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_BTN', 'column', 'PREVSCRIPT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '后置脚本',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_BTN', 'column', 'AFTERSCRIPT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点类型
   0，普通节点
   1，会签节点',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_BTN', 'column', 'NODETYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_BTN', 'column', 'SN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_BTN', 'column', 'DEFID'
go

ALTER TABLE BPM_NODE_BTN
   ADD CONSTRAINT PK_BPM_NODE_BTN PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_NODE_MESSAGE (
   ID                   NUMERIC(18,0)        NOT NULL,
   ACTDEFID             VARCHAR(64)          NULL,
   NODEID               VARCHAR(50)          NULL,
   MESSAGETYPE          SMALLINT             NULL,
   SUBJECT              VARCHAR(200)         NULL,
   TEMPLATE             TEXT                 NULL,
   ISSEND               SMALLINT             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程消息节点',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_MESSAGE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_MESSAGE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_MESSAGE', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_MESSAGE', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '消息接收人类型',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_MESSAGE', 'column', 'MESSAGETYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '消息主题',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_MESSAGE', 'column', 'SUBJECT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '消息模板',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_MESSAGE', 'column', 'TEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '确认发送',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_MESSAGE', 'column', 'ISSEND'
go

ALTER TABLE BPM_NODE_MESSAGE
   ADD CONSTRAINT PK_BPM_NODE_MESSAGE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_NODE_PRIVILEGE (
   PRIVILEGEID          NUMERIC(18,0)        NOT NULL,
   ACTDEFID             VARCHAR(128)         NULL,
   NODEID               VARCHAR(128)         NULL,
   PRIVILEGEMODE        SMALLINT             NULL,
   USERTYPE             SMALLINT             NULL,
   CMPNAMES             TEXT                 NULL,
   CMPIDS               TEXT                 NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点特权',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_PRIVILEGE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'Act流程发布ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_PRIVILEGE', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   ' 流程节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_PRIVILEGE', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '0=拥有所有特权
   1=允许直接处理
   2=允许一票制
   3=允许补签',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_PRIVILEGE', 'column', 'PRIVILEGEMODE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '0=发起人
   1=用户
   2=角色
   3=组织
   4=组织负责人
   5=岗位
   6=上下级
   7=用户属性
   8=组织属性
   9=本部门
   10=为某个节点的执行人
   11=动态计算(如来自指定的方法或接口，如可允许来自上个表单的用户选择)',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_PRIVILEGE', 'column', 'USERTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '特权人',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_PRIVILEGE', 'column', 'CMPNAMES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '特权人ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_PRIVILEGE', 'column', 'CMPIDS'
go

ALTER TABLE BPM_NODE_PRIVILEGE
   ADD CONSTRAINT PK_BPM_NODE_PRIVILEGE PRIMARY KEY NONCLUSTERED (PRIVILEGEID)
go

CREATE TABLE BPM_NODE_RULE (
   RULEID               NUMERIC(18,0)        NOT NULL,
   RULENAME             VARCHAR(128)         NOT NULL,
   CONDITIONCODE        TEXT                 NULL,
   ACTDEFID             VARCHAR(127)         NULL,
   NODEID               VARCHAR(50)          NULL,
   PRIORITY             NUMERIC(18,0)        NULL,
   TARGETNODE           VARCHAR(20)          NULL,
   TARGETNODENAME       VARCHAR(255)         NULL,
   MEMO                 VARCHAR(200)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程节点规则
   流程节点规则 是用于设计根据表单或其他流程变量来进行计算，以实现其规则的跳转
   CODE: node_rule',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_RULE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_RULE', 'column', 'RULEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '规则名称',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_RULE', 'column', 'RULENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '规则表达式',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_RULE', 'column', 'CONDITIONCODE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'Act流程发布ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_RULE', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_RULE', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '优先级别',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_RULE', 'column', 'PRIORITY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '跳转节点',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_RULE', 'column', 'TARGETNODE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '跳转节点名称',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_RULE', 'column', 'TARGETNODENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_RULE', 'column', 'MEMO'
go

ALTER TABLE BPM_NODE_RULE
   ADD CONSTRAINT PK_BPM_NODE_RULE PRIMARY KEY NONCLUSTERED (RULEID)
go

CREATE TABLE BPM_NODE_SCRIPT (
   ID                   NUMERIC(18,0)        NOT NULL,
   MEMO                 VARCHAR(50)          NULL,
   NODEID               VARCHAR(20)          NULL,
   ACTDEFID             VARCHAR(64)          NULL,
   SCRIPT               TEXT                 NULL,
   SCRIPTTYPE           NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程节点事件脚本',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SCRIPT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SCRIPT', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SCRIPT', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SCRIPT', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SCRIPT', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '脚本',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SCRIPT', 'column', 'SCRIPT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '脚本类型
               1.事件前置脚本
               2.事件后置脚本
               3.脚本节点
               4.任务分配脚本',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SCRIPT', 'column', 'SCRIPTTYPE'
go

ALTER TABLE BPM_NODE_SCRIPT
   ADD CONSTRAINT PK_BPM_NODE_SCRIPT PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_NODE_SET (
   SETID                NUMERIC(18,0)        NOT NULL,
   DEFID                NUMERIC(18,0)        NULL,
   NODENAME             VARCHAR(256)         NULL,
   NODEORDER            SMALLINT             NULL,
   NODEID               VARCHAR(128)         NULL,
   FORMTYPE             SMALLINT             NULL DEFAULT 0,
   FORMURL              VARCHAR(255)         NULL,
   FORMKEY              VARCHAR(50)        NULL,
   ACTDEFID             VARCHAR(127)         NULL,
   FORMDEFNAME          VARCHAR(255)         NULL,
   NODETYPE             SMALLINT             NULL,
   JOINTASKKEY          VARCHAR(128)         NULL,
   JOINTASKNAME         VARCHAR(256)         NULL,
   BEFOREHANDLER        VARCHAR(100)         NULL,
   AFTERHANDLER         VARCHAR(100)         NULL,
   JUMPTYPE             VARCHAR(32)          NULL,
   SETTYPE              SMALLINT             NULL,
   ISJUMPFORDEF         SMALLINT             NULL,
   ISHIDEOPTION         SMALLINT             NULL,
   ISHIDEPATH           SMALLINT             NULL,
   DETAILURL            VARCHAR(256)         NULL,
   ISALLOWMOBILE        SMALLINT             NULL,
   INFORMTYPE           VARCHAR(20)          NULL,
   PARENTACTDEFID       VARCHAR(127)         NULL,
   MOBILEFORMKEY        VARCHAR(50)          NULL,
   ISREQUIRED           SMALLINT             NULL DEFAULT 0,
   ISPOPUP              SMALLINT             NULL DEFAULT 1,
   OPINIONFIELD         VARCHAR(64)          NULL,
   OPINIONHTML          SMALLINT             NULL DEFAULT 1,
   SCOPE 				VARCHAR(256)		 NULL,
   SENDMSGTOCREATOR     SMALLINT,
   MOBILEFORMNAME       VARCHAR(64),
   ENABLEMOBILE			NUMERIC(1,0)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程节点设置',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'DEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点名',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'NODENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点顺序编号',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'NODEORDER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'activiti 节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '0=在线流程表单
   1=URL表单',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'FORMTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '当表单类型为1时，表单对应的url',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'FORMURL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单KEY',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'FORMKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'Act流程发布ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单名称',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'FORMDEFNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点类型',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'NODETYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '前置处理器',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'BEFOREHANDLER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '后置处理器',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'AFTERHANDLER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '跳转类型',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'JUMPTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点设置类型
   0.任务节点
   1.开始表单
   2.默认表单',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'SETTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '默认跳转',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'ISJUMPFORDEF'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否隐藏意见表单',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'ISHIDEOPTION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否隐藏路径',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'ISHIDEPATH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'URL明细',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'DETAILURL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否允许手机访问',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'ISALLOWMOBILE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '通知方式',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'INFORMTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'Act父流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'PARENTACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '手机表单key',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'MOBILEFORMKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否必填',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'ISREQUIRED'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否弹出',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'ISPOPUP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '意见回填字段',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'OPINIONFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '意见是否支持html',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'OPINIONHTML'
go
DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否允许手机表单',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SET', 'column', 'ENABLEMOBILE'
go

ALTER TABLE BPM_NODE_SET
   ADD CONSTRAINT PK_BPM_NODE_SET PRIMARY KEY NONCLUSTERED (SETID)
go

CREATE TABLE BPM_NODE_SIGN (
   SIGNID               NUMERIC(18,0)        NOT NULL,
   ACTDEFID             VARCHAR(127)         NULL,
   NODEID               VARCHAR(128)         NULL,
   VOTEAMOUNT           NUMERIC(18,0)        NULL,
   DECIDETYPE           SMALLINT             NOT NULL,
   VOTETYPE             SMALLINT             NULL,
   FLOWMODE             SMALLINT             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务会签设置',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SIGN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'Act流程发布ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SIGN', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SIGN', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '票数',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SIGN', 'column', 'VOTEAMOUNT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '决策方式
   1=pass 通过
   2=reject 拒绝',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SIGN', 'column', 'DECIDETYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '1=百分比
   2=绝对票数',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SIGN', 'column', 'VOTETYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '后续处理模式,
   1=满足条件则直接通过;
   2=所有任务结束后再通过.',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SIGN', 'column', 'FLOWMODE'
go

ALTER TABLE BPM_NODE_SIGN
   ADD CONSTRAINT PK_BPM_NODE_SIGN PRIMARY KEY NONCLUSTERED (SIGNID)
go

CREATE TABLE BPM_NODE_USER (
   NODEUSERID           NUMERIC(18,0)        NOT NULL,
   CMPIDS               TEXT                 NULL,
   CMPNAMES             TEXT                 NULL,
   SN                   NUMERIC(18,0)        NULL,
   ASSIGNTYPE           VARCHAR(20)          NOT NULL,
   COMPTYPE             SMALLINT             NULL,
   CONDITIONID          NUMERIC(18,0)        NULL,
   EXTRACTUSER          SMALLINT             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程节点人员',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_USER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点人员ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_USER', 'column', 'NODEUSERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户组件IDs',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_USER', 'column', 'CMPIDS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户组件名称',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_USER', 'column', 'CMPNAMES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '序号',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_USER', 'column', 'SN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指派人员类型
   0=发起人
   1=用户
   2=角色
   3=组织
   4=组织负责人
   5=岗位
   6=上下级
   7=用户属性
   8=组织属性
   9=本部门
   10=为某个节点的执行人
   11=动态计算(如来自指定的方法或接口，如可允许来自上个表单的用户选择)',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_USER', 'column', 'ASSIGNTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '计算类型
   0=or
   1=and
   2=exclude',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_USER', 'column', 'COMPTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '条件ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_USER', 'column', 'CONDITIONID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否抽取用户 
   0:不抽取 
   1:抽取
   2.二级抽取
   3.用户分组',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_USER', 'column', 'EXTRACTUSER'
go

ALTER TABLE BPM_NODE_USER
   ADD CONSTRAINT PK_BPM_NODE_USER PRIMARY KEY NONCLUSTERED (NODEUSERID)
go

CREATE TABLE BPM_NODE_WEBSERVICE (
   ID                   NUMERIC(18,0)        NOT NULL,
   ACTDEFID             VARCHAR(128)         NULL,
   NODEID               VARCHAR(128)         NULL,
   DOCUMENT             TEXT         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程webservice节点',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_WEBSERVICE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_WEBSERVICE', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点Id',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_WEBSERVICE', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'webservice地址',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_WEBSERVICE', 'column', 'DOCUMENT'
go

ALTER TABLE BPM_NODE_WEBSERVICE
   ADD CONSTRAINT PK_BPM_NODE_WEBSERVICE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_NODE_WS_PARAMS (
   ID                   NUMERIC(18,0)        NOT NULL,
   WEBSERVICEID         NUMERIC(18,0)        NULL,
   PARATYPE             NUMERIC(18,0)        NULL,
   VARID                NUMERIC(18,0)        NULL,
   WSNAME               VARCHAR(256)         NULL,
   TYPE                 VARCHAR(128)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程webservice节点参数',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_WS_PARAMS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_WS_PARAMS', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'webservice节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_WS_PARAMS', 'column', 'WEBSERVICEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '参数类型【1：表示输入参数，0：输出参数】',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_WS_PARAMS', 'column', 'PARATYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '变量id',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_WS_PARAMS', 'column', 'VARID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'webservice变量名称',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_WS_PARAMS', 'column', 'WSNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '变量类型【变量类型，string long date,等】',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_WS_PARAMS', 'column', 'TYPE'
go

ALTER TABLE BPM_NODE_WS_PARAMS
   ADD CONSTRAINT PK_BPM_NODE_WS_PARAMS PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_PRINT_TEMPLATE (
   ID                   NUMERIC(18,0)        NOT NULL,
   FORM_KEY             VARCHAR(50)        NULL,
   TEMAPALTE_NAME       VARCHAR(200)         NULL,
   IS_DEFAULT           SMALLINT             NULL,
   TABLEID              NUMERIC(18,0)        NULL,
   HTML                 TEXT                 NULL,
   TEMPLATE             TEXT                 NULL,
   ALIAS                VARCHAR(200)         NULL,
   IS_PRINT_IN_FINISH   NUMERIC(2,0)         NULL,
   IS_PRINT_IN_FORM     NUMERIC(2,0)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '打印模版',
   'user', @CURRENTUSER, 'table', 'BPM_PRINT_TEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_PRINT_TEMPLATE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单key',
   'user', @CURRENTUSER, 'table', 'BPM_PRINT_TEMPLATE', 'column', 'FORM_KEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版名称',
   'user', @CURRENTUSER, 'table', 'BPM_PRINT_TEMPLATE', 'column', 'TEMAPALTE_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否默认',
   'user', @CURRENTUSER, 'table', 'BPM_PRINT_TEMPLATE', 'column', 'IS_DEFAULT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRINT_TEMPLATE', 'column', 'TABLEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版HTML',
   'user', @CURRENTUSER, 'table', 'BPM_PRINT_TEMPLATE', 'column', 'HTML'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版',
   'user', @CURRENTUSER, 'table', 'BPM_PRINT_TEMPLATE', 'column', 'TEMPLATE'
go

ALTER TABLE BPM_PRINT_TEMPLATE
   ADD CONSTRAINT PK_BPM_PRINT_TEMPLATE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_PRO_CPTO (
   COPY_ID              NUMERIC(18,0)        NOT NULL,
   ACACT_INST_ID        NUMERIC(18,0)        NOT NULL,
   RUN_ID               NUMERIC(18,0)        NOT NULL,
   NODE_KEY             VARCHAR(100)         NULL,
   NODE_NAME            VARCHAR(100)         NULL,
   CC_UID               NUMERIC(18,0)        NULL,
   CC_UNAME             VARCHAR(50)          NULL,
   CC_TIME              DATETIME             NULL,
   IS_READED            SMALLINT             NULL,
   FILL_OPINION         VARCHAR(2000)        NULL,
   SUBJECT              VARCHAR(300)         NULL,
   READ_TIME            DATETIME             NULL,
   CP_TYPE              SMALLINT             NULL,
   CREATE_ID            NUMERIC(18,0)        NULL,
   CREATOR              VARCHAR(50)          NULL,
   DEF_TYPEID           NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程抄送转发',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '抄送主键ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'COPY_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'ACT流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'ACACT_INST_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'PRO流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'RUN_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点Key',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'NODE_KEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点名称',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'NODE_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '抄送人名ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'CC_UID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '抄送人名',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'CC_UNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '抄送时间',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'CC_TIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否已阅
   0=未读
   1=已读',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'IS_READED'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '填写意见',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'FILL_OPINION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程标题',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'SUBJECT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '阅读时间',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'READ_TIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '1=抄送   在任务处理时，可以指定抄送人员进行任务抄送转发
   2=转发  在流程归档后，进行转发处理',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'CP_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发起人ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'CREATE_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发起人名',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程分类ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_CPTO', 'column', 'DEF_TYPEID'
go

ALTER TABLE BPM_PRO_CPTO
   ADD CONSTRAINT PK_BPM_PRO_CPTO PRIMARY KEY NONCLUSTERED (COPY_ID)
go

CREATE TABLE BPM_PRO_RUN (
   RUNID                NUMERIC(18,0)        NOT NULL,
   DEFID                NUMERIC(18,0)        NULL,
   BUSINESSKEY_NUM		NUMERIC(18,0)	     NULL,
   PROCESSNAME          VARCHAR(256)         NULL,
   SUBJECT              VARCHAR(600)         NULL,
   CREATORID            NUMERIC(18,0)        NULL,
   CREATOR              VARCHAR(128)         NULL,
   CREATETIME           DATETIME             NULL,
   BUSDESCP             VARCHAR(3000)        NULL,
   ACTINSTID            NUMERIC(18,0)        NULL,
   STATUS               SMALLINT             NULL,
   ACTDEFID             VARCHAR(256)         NULL,
   BUSINESSKEY          VARCHAR(255)         NULL,
   BUSINESSURL          VARCHAR(255)         NULL,
   ENDTIME              DATETIME             NULL,
   DURATION             NUMERIC(18,0)        NULL,
   PKNAME               VARCHAR(50)          NULL,
   TABLENAME            VARCHAR(50)          NULL,
   PARENTID             NUMERIC(18,0)        NULL,
   STARTORGID           NUMERIC(18,0)        NULL,
   STARTORGNAME         VARCHAR(200)         NULL,
   FORMDEFID            NUMERIC(18,0)        NULL,
   TYPEID               NUMERIC(18,0)        NULL,
   DSALIAS              VARCHAR(50)          NULL,
   FLOWKEY              VARCHAR(50)          NULL,
   FORMTYPE             SMALLINT             NULL,
   FORMKEYURL           VARCHAR(50)          NULL,
   LASTSUBMITDURATION   NUMERIC(18,0)        NULL,
   ISFORMAL             SMALLINT             NULL,
   RELRUNID				NUMERIC(18,0)		 NULL,
   GLOBALFLOWNO         VARCHAR(256)         NULL,
   STARTNODE            VARCHAR(50)          NULL,
   STARTFROMMOBILE		NUMERIC(1,0)
)

go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程实例扩展
   Code:PRO_RUN',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN'
go


DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否从手机启动',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'STARTFROMMOBILE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'DEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义名称',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'PROCESSNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程实例标题',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'SUBJECT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'CREATORID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '业务表单简述',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'BUSDESCP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'ACT流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'ACTINSTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '状态
   0=草稿
   1=启动
   2=正在运行
   3=正常结束
   
   ',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'STATUS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'ACT流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '业务键',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'BUSINESSKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '业务明细url
   
   可相对路径，也可绝对路径
   如:http://192.168.1.8:8080/bpm/fund/get.ht?fundId={0}
   或:/bpm/fund/fundId={0}
   ',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'BUSINESSURL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '结束时间',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'ENDTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '持续时间',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'DURATION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键名称',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'PKNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表名',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'TABLENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '父流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'PARENTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发起人所在组织Id',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'STARTORGID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发起人所在组织名称',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'STARTORGNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单定义',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'FORMDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分类ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'TYPEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据源',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'DSALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义KEY',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'FLOWKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单类型',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'FORMTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单Key或Url',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'FORMKEYURL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '基于最后一次提交，执行持续时间总长',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'LASTSUBMITDURATION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否正式流程实例',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'ISFORMAL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '关联实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'RELRUNID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '开始节点',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'STARTNODE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '业务数据关联查询用到索引',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'BUSINESSKEY_NUM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '全局流水号',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN', 'column', 'GLOBALFLOWNO'
go


ALTER TABLE BPM_PRO_RUN
   ADD CONSTRAINT PK_BPM_PRO_RUN PRIMARY KEY NONCLUSTERED (RUNID)
go

CREATE TABLE BPM_PRO_RUN_HIS (
   RUNID                NUMERIC(18,0)        NOT NULL,
   DEFID                NUMERIC(18,0)        NULL,
   BUSINESSKEY_NUM		NUMERIC(18,0)	     NULL,
   PROCESSNAME          VARCHAR(256)         NULL,
   SUBJECT              VARCHAR(600)         NULL,
   CREATORID            NUMERIC(18,0)        NULL,
   CREATOR              VARCHAR(128)         NULL,
   CREATETIME           DATETIME             NULL,
   BUSDESCP             VARCHAR(3000)        NULL,
   ACTINSTID            NUMERIC(18,0)        NULL,
   STATUS               SMALLINT             NULL,
   ACTDEFID             VARCHAR(256)         NULL,
   BUSINESSKEY          VARCHAR(255)         NULL,
   BUSINESSURL          VARCHAR(255)         NULL,
   ENDTIME              DATETIME             NULL,
   DURATION             NUMERIC(18,0)        NULL,
   PKNAME               VARCHAR(50)          NULL,
   TABLENAME            VARCHAR(50)          NULL,
   PARENTID             NUMERIC(18,0)        NULL,
   STARTORGID           NUMERIC(18,0)        NULL,
   STARTORGNAME         VARCHAR(200)         NULL,
   FORMDEFID            NUMERIC(18,0)        NULL,
   TYPEID               NUMERIC(18,0)        NULL,
   DSALIAS              VARCHAR(50)          NULL,
   FLOWKEY              VARCHAR(50)          NULL,
   FORMTYPE             SMALLINT             NULL,
   FORMKEYURL           VARCHAR(50)          NULL,
   LASTSUBMITDURATION   NUMERIC(18,0)        NULL,
   ISFORMAL             SMALLINT             NULL,
   RELRUNID				NUMERIC(18,0)		 NULL,
   GLOBALFLOWNO         VARCHAR(256)         NULL,
   STARTNODE            VARCHAR(50)          NULL,
   STARTFROMMOBILE 		NUMERIC(1,0)		 NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程实例扩展
   Code:PRO_RUN',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'DEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否从手机启动',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'STARTFROMMOBILE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义名称',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'PROCESSNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程实例标题',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'SUBJECT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'CREATORID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '业务表单简述',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'BUSDESCP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'ACT流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'ACTINSTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '状态
   0=草稿
   1=启动
   2=正在运行
   3=正常结束
   
   ',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'STATUS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'ACT流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '业务键',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'BUSINESSKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '业务明细url
   
   可相对路径，也可绝对路径
   如:http://192.168.1.8:8080/bpm/fund/get.ht?fundId={0}
   或:/bpm/fund/fundId={0}
   ',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'BUSINESSURL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '结束时间',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'ENDTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '持续时间',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'DURATION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键名称',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'PKNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表名',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'TABLENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '父流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'PARENTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发起人所在组织Id',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'STARTORGID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发起人所在组织名称',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'STARTORGNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单定义',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'FORMDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分类ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'TYPEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据源',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'DSALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义KEY',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'FLOWKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'formType',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'FORMTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'formType',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'FORMKEYURL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '基于最后一次提交，执行持续时间总长',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'LASTSUBMITDURATION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否正式流程实例',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'ISFORMAL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '关联实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'RELRUNID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '开始节点',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'STARTNODE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '全局流水号',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'GLOBALFLOWNO'
go

ALTER TABLE BPM_PRO_RUN_HIS
   ADD CONSTRAINT PK_BPM_PRO_RUN_HIS PRIMARY KEY NONCLUSTERED (RUNID)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '业务数据关联查询用到索引',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_RUN_HIS', 'column', 'BUSINESSKEY_NUM'
go

CREATE TABLE BPM_PRO_STATUS (
   ID                   NUMERIC(18,0)        NULL,
   ACTINSTID            NUMERIC(18,0)        NULL,
   NODEID               VARCHAR(64)          NULL,
   NODENAME             VARCHAR(255)         NULL,
   STATUS               SMALLINT             NULL,
   LASTUPDATETIME       DATETIME             NULL,
   ACTDEFID             VARCHAR(64)          NULL,
   DEFID                NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程节点状态',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_STATUS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_STATUS', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_STATUS', 'column', 'ACTINSTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_STATUS', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点名称',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_STATUS', 'column', 'NODENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '状态',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_STATUS', 'column', 'STATUS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '最后更新时间',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_STATUS', 'column', 'LASTUPDATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'ACT流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_STATUS', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_STATUS', 'column', 'DEFID'
go

CREATE TABLE BPM_PRO_TRANSTO (
   ID                   NUMERIC(18,0)        NOT NULL,
   ACTINSTID            NUMERIC(18,0)        NULL,
   TASKID               NUMERIC(18,0)        NULL,
   TRANSTYPE            SMALLINT             NULL,
   ACTION               SMALLINT             NULL,
   CREATEUSERID         NUMERIC(18,0)        NULL,
   CREATETIME           DATETIME             NULL,
   TRANSRESULT          SMALLINT             NULL,
   ASSIGNEE             VARCHAR(256)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程流转',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_TRANSTO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_TRANSTO', 'column', 'ACTINSTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务ID',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_TRANSTO', 'column', 'TASKID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流转类型',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_TRANSTO', 'column', 'TRANSTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '处理动作',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_TRANSTO', 'column', 'ACTION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_TRANSTO', 'column', 'CREATEUSERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_TRANSTO', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '被流转人投票结果,1同意,2反对',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_TRANSTO', 'column', 'TRANSRESULT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流转接收人',
   'user', @CURRENTUSER, 'table', 'BPM_PRO_TRANSTO', 'column', 'ASSIGNEE'
go

ALTER TABLE BPM_PRO_TRANSTO
   ADD CONSTRAINT PK_BPM_PRO_TRANSTO PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_REFER_DEFINITION (
   ID                   NUMERIC(18,0)        NOT NULL,
   DEFID                VARCHAR(200)         NULL,
   REFER_DEFKEY         VARCHAR(128)         NULL,
   CREATETIME           DATETIME             NULL,
   CREATEID             NUMERIC(18,0)        NULL,
   UPDATETIME           DATETIME             NULL,
   STATE                SMALLINT             NULL,
   REMARK               VARCHAR(400)         NULL,
   SUBJECT              VARCHAR(200)         NULL,
   UPDATEID             NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程引用定义',
   'user', @CURRENTUSER, 'table', 'BPM_REFER_DEFINITION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_REFER_DEFINITION', 'column', 'DEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程应用定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_REFER_DEFINITION', 'column', 'REFER_DEFKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'BPM_REFER_DEFINITION', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人ID',
   'user', @CURRENTUSER, 'table', 'BPM_REFER_DEFINITION', 'column', 'CREATEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程状态',
   'user', @CURRENTUSER, 'table', 'BPM_REFER_DEFINITION', 'column', 'STATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'BPM_REFER_DEFINITION', 'column', 'REMARK'
go

ALTER TABLE BPM_REFER_DEFINITION
   ADD CONSTRAINT PK_BPM_REFER_DEFINITION PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_RUN_LOG (
   ID                   NUMERIC(18,0)        NOT NULL,
   USERID               NUMERIC(18,0)        NULL,
   USERNAME             VARCHAR(50)          NULL,
   CREATETIME           DATETIME             NULL,
   OPERATORTYPE         SMALLINT             NULL,
   MEMO                 VARCHAR(300)         NULL,
   RUNID                NUMERIC(18,0)        NULL,
   PROCESSSUBJECT       VARCHAR(300)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '工作流运行日志',
   'user', @CURRENTUSER, 'table', 'BPM_RUN_LOG'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'BPM_RUN_LOG', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户名',
   'user', @CURRENTUSER, 'table', 'BPM_RUN_LOG', 'column', 'USERNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '操作时间',
   'user', @CURRENTUSER, 'table', 'BPM_RUN_LOG', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '操作类型',
   'user', @CURRENTUSER, 'table', 'BPM_RUN_LOG', 'column', 'OPERATORTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'BPM_RUN_LOG', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程运行ID',
   'user', @CURRENTUSER, 'table', 'BPM_RUN_LOG', 'column', 'RUNID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程标题',
   'user', @CURRENTUSER, 'table', 'BPM_RUN_LOG', 'column', 'PROCESSSUBJECT'
go

ALTER TABLE BPM_RUN_LOG
   ADD CONSTRAINT PK_BPM_RUN_LOG PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_SUBTABLE_RIGHTS (
   ID                   NUMERIC(18,0)        NOT NULL,
   ACTDEFID             VARCHAR(100)         NULL,
   NODEID               VARCHAR(50)          NULL,
   TABLEID              NUMERIC(18,0)        NULL,
   PERMISSIONTYPE       SMALLINT             NULL,
   PERMISSIONSETING     VARCHAR(2000)        NULL,
   PARENTACTDEFID       VARCHAR(100)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '子表权限',
   'user', @CURRENTUSER, 'table', 'BPM_SUBTABLE_RIGHTS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_SUBTABLE_RIGHTS', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_SUBTABLE_RIGHTS', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '子表表ID',
   'user', @CURRENTUSER, 'table', 'BPM_SUBTABLE_RIGHTS', 'column', 'TABLEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '权限类型(1,简单配置,2,脚本)',
   'user', @CURRENTUSER, 'table', 'BPM_SUBTABLE_RIGHTS', 'column', 'PERMISSIONTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '权限配置',
   'user', @CURRENTUSER, 'table', 'BPM_SUBTABLE_RIGHTS', 'column', 'PERMISSIONSETING'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '父流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_SUBTABLE_RIGHTS', 'column', 'PARENTACTDEFID'
go

ALTER TABLE BPM_SUBTABLE_RIGHTS
   ADD CONSTRAINT PK_BPM_SUBTABLE_RIGHTS PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_TASK_DUE (
   TASKDUEID            NUMERIC(18,0)        NOT NULL,
   ACTDEFID             VARCHAR(127)         NULL,
   NODEID               VARCHAR(50)          NULL,
   REMINDERSTART        NUMERIC(18,0)        NOT NULL,
   REMINDEREND          NUMERIC(18,0)        NULL,
   TIMES                NUMERIC(18,0)        NULL,
   MAILCONTENT          TEXT                 NULL,
   MSGCONTENT           TEXT                 NULL,
   SMSCONTENT           TEXT                 NULL,
   ACTION               NUMERIC(18,0)        NULL,
   SCRIPT               VARCHAR(2000)        NULL,
   COMPLETETIME         NUMERIC(18,0)        NULL,
   CONDEXP              TEXT                 NULL,
   NAME                 VARCHAR(50)          NULL,
   RELATIVENODEID       VARCHAR(100)         NULL,
   RELATIVENODETYPE     NUMERIC(18,0)        NULL,
   RELATIVETIMETYPE     NUMERIC(18,0)        NULL,
   ASSIGNERID           NUMERIC(18,0)        NULL,
   ASSIGNERNAME         VARCHAR(50)          NULL,
   WARNINGSETJSON       VARCHAR(2000)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务节点催办时间设置',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '时间设置ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'TASKDUEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '催办开始时间(相对于任务创建时间，多少工作日)',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'REMINDERSTART'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '催办结束时间(相对于催办开始时间)',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'REMINDEREND'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '催办次数',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'TIMES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '催办提醒短信内容',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'MAILCONTENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '催办邮件模板内容',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'MSGCONTENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '催办邮件模板内容',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'SMSCONTENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务到期处理动作
   0=不做任何处理
   1=流程自动往下跳转
   2=结束该流程
   3=调用指定方法 如 service.xxMethod 该字段直接存储该值
   ',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'ACTION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '执行脚本',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'SCRIPT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '办结时间',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'COMPLETETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '条件表达式',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'CONDEXP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '名称',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '相对节点的节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'RELATIVENODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '相对节点的动作0:创建,1:完成',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'RELATIVENODETYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '相对时间类型0:工作日，1:日历日',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'RELATIVETIMETYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指定的交办人ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'ASSIGNERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指定的交办人名称',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'ASSIGNERNAME'
go
DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务预警',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_DUE', 'column', 'WARNINGSETJSON'
go


ALTER TABLE BPM_TASK_DUE
   ADD CONSTRAINT PK_BPM_TASK_DUE PRIMARY KEY NONCLUSTERED (TASKDUEID)
go

CREATE TABLE BPM_TASK_EXE (
   ID                   NUMERIC(18,0)        NOT NULL,
   TASKID               NUMERIC(18,0)        NULL,
   ASSIGNEE_ID          NUMERIC(18,0)        NULL,
   ASSIGNEE_NAME        VARCHAR(50)          NULL,
   OWNER_ID             NUMERIC(18,0)        NULL,
   OWNER_NAME           VARCHAR(200)         NULL,
   SUBJECT              VARCHAR(400)         NULL,
   STATUS               SMALLINT             NULL,
   MEMO                 VARCHAR(4000)        NULL,
   CRATETIME            DATETIME             NULL,
   ACT_INST_ID          NUMERIC(18,0)        NULL,
   TASK_NAME            VARCHAR(400)         NULL,
   TASK_DEF_KEY         VARCHAR(64)          NULL,
   EXE_TIME             DATETIME             NULL,
   EXE_USER_ID          NUMERIC(18,0)        NULL,
   EXE_USER_NAME        VARCHAR(256)         NULL,
   ASSIGN_TYPE          SMALLINT             NULL,
   RUNID                NUMERIC(18,0)        NULL,
   TYPE_ID              NUMERIC(18,0)        NULL,
   CREATORID            NUMERIC(18,0)        NULL,
   CREATOR              VARCHAR(256)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务转办代理',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'TASKID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '承接人ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'ASSIGNEE_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '承接人名称',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'ASSIGNEE_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务所有人ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'OWNER_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务所有人',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'OWNER_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '实例标题',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'SUBJECT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '状态',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'STATUS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '原因备注',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'CRATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'ACT_INST_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务名',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'TASK_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务Key',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'TASK_DEF_KEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '完成时间',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'EXE_TIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '执行人id',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'EXE_USER_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '执行人名',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'EXE_USER_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '1=代理
   2=转办',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'ASSIGN_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程runID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'RUNID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '类型ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'TYPE_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'CREATORID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_EXE', 'column', 'CREATOR'
go

ALTER TABLE BPM_TASK_EXE
   ADD CONSTRAINT PK_BPM_TASK_EXE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_TASK_FORK (
   TASKFORKID           NUMERIC(18,0)        NOT NULL,
   ACTINSTID            NUMERIC(18,0)        NULL,
   FORKTASKNAME         VARCHAR(256)         NULL,
   FORKTASKKEY          VARCHAR(256)         NULL,
   FORKSN               NUMERIC(18,0)        NULL,
   FORKCOUNT            NUMERIC(18,0)        NULL,
   FININSHCOUNT         NUMERIC(18,0)        NULL,
   FORKTIME             DATETIME             NULL,
   JOINTASKNAME         VARCHAR(256)         NULL,
   JOINTASKKEY          VARCHAR(256)         NULL,
   FORKTOKENS           VARCHAR(512)         NULL,
   FORKTOKENPRE         VARCHAR(64)          NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程任务分发汇总',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_FORK'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_FORK', 'column', 'TASKFORKID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_FORK', 'column', 'ACTINSTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分发任务名称',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_FORK', 'column', 'FORKTASKNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分发任务Key',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_FORK', 'column', 'FORKTASKKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分发序号',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_FORK', 'column', 'FORKSN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分发个数',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_FORK', 'column', 'FORKCOUNT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '完成个数',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_FORK', 'column', 'FININSHCOUNT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分发时间',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_FORK', 'column', 'FORKTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '汇总任务名称',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_FORK', 'column', 'JOINTASKNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '汇总任务Key',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_FORK', 'column', 'JOINTASKKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分发令牌号
   格式如：
   T_1_1,T_1_2,T_1_3,
   或 
   T_1,T_2,T_3,
   ',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_FORK', 'column', 'FORKTOKENS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '格式为T_
   或格式T_1
   或T_1_2等',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_FORK', 'column', 'FORKTOKENPRE'
go

ALTER TABLE BPM_TASK_FORK
   ADD CONSTRAINT PK_BPM_TASK_FORK PRIMARY KEY NONCLUSTERED (TASKFORKID)
go

CREATE TABLE BPM_TASK_OPINION (
   OPINIONID            NUMERIC(18,0)        NOT NULL,
   ACTDEFID             VARCHAR(127)         NULL,
   TASKNAME             VARCHAR(255)         NULL,
   TASKKEY              VARCHAR(64)          NULL,
   TASKID               NUMERIC(18,0)        NULL,
   TASKTOKEN            VARCHAR(50)          NULL,
   ACTINSTID            NUMERIC(18,0)        NULL,
   STARTTIME            DATETIME             NULL,
   ENDTIME              DATETIME             NULL,
   DURTIME              NUMERIC(18,0)        NULL,
   EXEUSERID            NUMERIC(18,0)        NULL,
   EXEFULLNAME          VARCHAR(127)         NULL,
   OPINION              TEXT                 NULL,
   CHECKSTATUS          SMALLINT             NULL,
   FORMDEFID            NUMERIC(18,0)        NULL,
   FIELDNAME            VARCHAR(50)          NULL,
   SUPEREXECUTION       NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程任务审批意见',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '意见ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'OPINIONID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务名称',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'TASKNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务定义Key',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'TASKKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务Id',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'TASKID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务令牌',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'TASKTOKEN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程实例Id',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'ACTINSTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '执行开始时间',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'STARTTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '结束时间',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'ENDTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '持续时间',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'DURTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '执行人ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'EXEUSERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '执行人名',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'EXEFULLNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '审批意见',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'OPINION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '审批状态
   1=同意
   2=反对
   3=驳回
   0=弃权
   4=追回',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'CHECKSTATUS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'FORMDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单名',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'FIELDNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '父流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_OPINION', 'column', 'SUPEREXECUTION'
go

ALTER TABLE BPM_TASK_OPINION
   ADD CONSTRAINT PK_BPM_TASK_OPINION PRIMARY KEY NONCLUSTERED (OPINIONID)
go

CREATE TABLE BPM_TASK_READ (
   ID                   NUMERIC(18,0)        NOT NULL,
   ACTINSTID            NUMERIC(18,0)        NULL,
   TASKID               NUMERIC(18,0)        NULL,
   USERID               NUMERIC(18,0)        NULL,
   USERNAME             VARCHAR(100)         NULL,
   CREATETIME           DATETIME             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务已读',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_READ'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_READ', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_READ', 'column', 'ACTINSTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_READ', 'column', 'TASKID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_READ', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户名',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_READ', 'column', 'USERNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_READ', 'column', 'CREATETIME'
go

ALTER TABLE BPM_TASK_READ
   ADD CONSTRAINT PK_BPM_TASK_READ PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_TASK_REMINDERSTATE (
   ID                   NUMERIC(18,0)        NOT NULL,
   ACTDEFID             VARCHAR(127)         NULL,
   TASKID               NUMERIC(18,0)        NULL,
   REMINDERTIME         DATETIME             NULL,
   USERID               NUMERIC(18,0)        NULL,
   ACTINSTANCEID        NUMERIC(18,0)        NULL,
   REMINDTYPE           SMALLINT             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务催办执行情况',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_REMINDERSTATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_REMINDERSTATE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_REMINDERSTATE', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_REMINDERSTATE', 'column', 'TASKID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '催办时间',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_REMINDERSTATE', 'column', 'REMINDERTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_REMINDERSTATE', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_REMINDERSTATE', 'column', 'ACTINSTANCEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '提醒类型(1，消息提醒,2,完成流程办结的处理动作)',
   'user', @CURRENTUSER, 'table', 'BPM_TASK_REMINDERSTATE', 'column', 'REMINDTYPE'
go

ALTER TABLE BPM_TASK_REMINDERSTATE
   ADD CONSTRAINT PK_BPM_TASK_REMINDERSTATE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BPM_TKSIGN_DATA (
   DATAID               NUMERIC(18,0)        NOT NULL,
   ACTDEFID             VARCHAR(127)         NULL,
   ACTINSTID            NUMERIC(18,0)        NOT NULL,
   NODENAME             VARCHAR(128)         NULL,
   NODEID               VARCHAR(127)         NOT NULL,
   TASKID               NUMERIC(18,0)        NULL,
   VOTEUSERID           VARCHAR(1000)        NOT NULL,
   VOTEUSERNAME         VARCHAR(1000)        NULL,
   VOTETIME             DATETIME             NULL,
   ISAGREE              SMALLINT             NULL,
   CONTENT              VARCHAR(200)         NULL,
   SIGNNUMS             NUMERIC(18,0)        NULL DEFAULT 1,
   ISCOMPLETED          SMALLINT             NULL DEFAULT 0,
   BATCH                SMALLINT             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务会签数据',
   'user', @CURRENTUSER, 'table', 'BPM_TKSIGN_DATA'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_TKSIGN_DATA', 'column', 'DATAID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_TKSIGN_DATA', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_TKSIGN_DATA', 'column', 'ACTINSTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程节点名称',
   'user', @CURRENTUSER, 'table', 'BPM_TKSIGN_DATA', 'column', 'NODENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程节点Id',
   'user', @CURRENTUSER, 'table', 'BPM_TKSIGN_DATA', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '会签任务Id',
   'user', @CURRENTUSER, 'table', 'BPM_TKSIGN_DATA', 'column', 'TASKID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '投票人ID',
   'user', @CURRENTUSER, 'table', 'BPM_TKSIGN_DATA', 'column', 'VOTEUSERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '投票人名',
   'user', @CURRENTUSER, 'table', 'BPM_TKSIGN_DATA', 'column', 'VOTEUSERNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '投票时间',
   'user', @CURRENTUSER, 'table', 'BPM_TKSIGN_DATA', 'column', 'VOTETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否同意
   0=弃权票
   1=同意
   2=拒绝
   
   跟task_sign中的decideType是一样',
   'user', @CURRENTUSER, 'table', 'BPM_TKSIGN_DATA', 'column', 'ISAGREE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '投票意见内容',
   'user', @CURRENTUSER, 'table', 'BPM_TKSIGN_DATA', 'column', 'CONTENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '该节点会签次号',
   'user', @CURRENTUSER, 'table', 'BPM_TKSIGN_DATA', 'column', 'SIGNNUMS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否完成
   1=完成
   0=未完成
   
   会签是否结束',
   'user', @CURRENTUSER, 'table', 'BPM_TKSIGN_DATA', 'column', 'ISCOMPLETED'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '批次',
   'user', @CURRENTUSER, 'table', 'BPM_TKSIGN_DATA', 'column', 'BATCH'
go

ALTER TABLE BPM_TKSIGN_DATA
   ADD CONSTRAINT PK_BPM_TKSIGN_DATA PRIMARY KEY NONCLUSTERED (DATAID)
go

CREATE TABLE BPM_USER_CONDITION (
   ID                   NUMERIC(18,0)        NOT NULL,
   SETID                NUMERIC(18,0)        NULL,
   CONDITIONNAME        VARCHAR(127)         NULL,
   ACTDEFID             VARCHAR(127)         NULL,
   NODEID               VARCHAR(128)         NULL,
   CONDITIONCODE        TEXT                 NULL,
   SN                   NUMERIC(38,0)        NULL,
   CONDITIONSHOW        TEXT                 NULL,
   CONDITIONTYPE        SMALLINT             NULL,
   GROUPNO              SMALLINT             NULL,
   FORMIDENTITY         VARCHAR(30)          NULL,
   PARENTACTDEFID       VARCHAR(128)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户选择条件',
   'user', @CURRENTUSER, 'table', 'BPM_USER_CONDITION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点设置ID',
   'user', @CURRENTUSER, 'table', 'BPM_USER_CONDITION', 'column', 'SETID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '规则名称',
   'user', @CURRENTUSER, 'table', 'BPM_USER_CONDITION', 'column', 'CONDITIONNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '实例Id',
   'user', @CURRENTUSER, 'table', 'BPM_USER_CONDITION', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点名称',
   'user', @CURRENTUSER, 'table', 'BPM_USER_CONDITION', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '条件规则',
   'user', @CURRENTUSER, 'table', 'BPM_USER_CONDITION', 'column', 'CONDITIONCODE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '批次',
   'user', @CURRENTUSER, 'table', 'BPM_USER_CONDITION', 'column', 'SN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '规则显示字符串',
   'user', @CURRENTUSER, 'table', 'BPM_USER_CONDITION', 'column', 'CONDITIONSHOW'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '人员规则的类型',
   'user', @CURRENTUSER, 'table', 'BPM_USER_CONDITION', 'column', 'CONDITIONTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '规则分组号',
   'user', @CURRENTUSER, 'table', 'BPM_USER_CONDITION', 'column', 'GROUPNO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '条件标识',
   'user', @CURRENTUSER, 'table', 'BPM_USER_CONDITION', 'column', 'FORMIDENTITY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '父流程定义ID',
   'user', @CURRENTUSER, 'table', 'BPM_USER_CONDITION', 'column', 'PARENTACTDEFID'
go

ALTER TABLE BPM_USER_CONDITION
   ADD CONSTRAINT PK_BPM_USER_CONDITION PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BUS_QUERY_FILTER (
   ID                   NUMERIC(18,0)        NOT NULL,
   RULEID               NUMERIC(18,0)        NULL,
   TABLENAME            VARCHAR(256)         NULL,
   FILTERNAME           VARCHAR(256)         NULL,
   FILTERDESC           TEXT                 NULL,
   FILTERKEY            VARCHAR(256)         NULL,
   QUERYPARAMETER       TEXT                 NULL,
   SORTPARAMETER        TEXT                 NULL,
   ISSHARE              SMALLINT             NULL DEFAULT 0,
   CREATETIME           DATETIME             NULL,
   CREATEBY             NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '查询过滤',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_FILTER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '规则ID',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_FILTER', 'column', 'RULEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表名',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_FILTER', 'column', 'TABLENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '过滤名称',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_FILTER', 'column', 'FILTERNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '过滤描述',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_FILTER', 'column', 'FILTERDESC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '过滤条件Key',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_FILTER', 'column', 'FILTERKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '查询参数',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_FILTER', 'column', 'QUERYPARAMETER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序参数',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_FILTER', 'column', 'SORTPARAMETER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否共享',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_FILTER', 'column', 'ISSHARE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_FILTER', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人ID',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_FILTER', 'column', 'CREATEBY'
go

ALTER TABLE BUS_QUERY_FILTER
   ADD CONSTRAINT PK_BUS_QUERY_FILTER PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BUS_QUERY_RULE (
   ID                   NUMERIC(18,0)        NOT NULL,
   TABLENAME            VARCHAR(128)         NULL,
   NEEDPAGE             SMALLINT             NULL DEFAULT 1,
   PAGESIZE             NUMERIC(18,0)        NULL,
   ISQUERY              SMALLINT             NULL DEFAULT 0,
   ISFILTER             SMALLINT             NULL DEFAULT 0,
   DISPLAYFIELD         TEXT                 NULL,
   FILTERFIELD          TEXT                 NULL,
   SORTFIELD            TEXT                 NULL,
   EXPORTFIELD          TEXT                 NULL,
   PRINTFIELD           TEXT                 NULL,
   CREATETIME           DATETIME             NULL,
   CREATEBY             NUMERIC(18,0)        NULL,
   UPDATETIME           DATETIME             NULL,
   UPDATEBY             NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '高级查询规则',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_RULE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表名',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_RULE', 'column', 'TABLENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否分页',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_RULE', 'column', 'NEEDPAGE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分页大小',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_RULE', 'column', 'PAGESIZE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '初始是否进行查询',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_RULE', 'column', 'ISQUERY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否默认条件',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_RULE', 'column', 'ISFILTER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '显示字段',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_RULE', 'column', 'DISPLAYFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '过滤器字段',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_RULE', 'column', 'FILTERFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序字段',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_RULE', 'column', 'SORTFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '导出字段',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_RULE', 'column', 'EXPORTFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '打印字段',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_RULE', 'column', 'PRINTFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_RULE', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人ID',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_RULE', 'column', 'CREATEBY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '更新时间',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_RULE', 'column', 'UPDATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '更新人ID',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_RULE', 'column', 'UPDATEBY'
go

ALTER TABLE BUS_QUERY_RULE
   ADD CONSTRAINT PK_BUS_QUERY_RULE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BUS_QUERY_SETTING (
   ID                   NUMERIC(18,0)        NOT NULL,
   TABLENAME            VARCHAR(100)         NULL,
   DISPLAYFIELD         TEXT                 NULL,
   USERID               NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '查询设置',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_SETTING'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表名',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_SETTING', 'column', 'TABLENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '显示字段',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_SETTING', 'column', 'DISPLAYFIELD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_SETTING', 'column', 'USERID'
go

ALTER TABLE BUS_QUERY_SETTING
   ADD CONSTRAINT PK_BUS_QUERY_SETTING PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE BUS_QUERY_SHARE (
   ID                   NUMERIC(18,0)        NOT NULL,
   FILTERID             NUMERIC(18,0)        NULL,
   SHARERIGHT           TEXT                 NULL,
   SHARERID             NUMERIC(18,0)        NULL,
   CREATETIME           DATETIME             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '查询过滤共享 ',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_SHARE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '过滤ID',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_SHARE', 'column', 'FILTERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '共享权限',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_SHARE', 'column', 'SHARERIGHT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '共享人ID',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_SHARE', 'column', 'SHARERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'BUS_QUERY_SHARE', 'column', 'CREATETIME'
go

ALTER TABLE BUS_QUERY_SHARE
   ADD CONSTRAINT PK_BUS_QUERY_SHARE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE MOBILE_USER_INFO (
   USERID               NUMERIC(18,0)        NOT NULL,
   USERNAME             VARCHAR(127)         NULL,
   IDCARD               VARCHAR(40)          NULL
)
go

ALTER TABLE MOBILE_USER_INFO
   ADD CONSTRAINT PK_MOBILE_USER_INFO PRIMARY KEY NONCLUSTERED (USERID)
go

CREATE TABLE OUT_MAIL (
   MAILID               NUMERIC(18,0)        NOT NULL,
   TITLE                VARCHAR(512)         NULL,
   CONTENT              TEXT                 NULL,
   SENDERADDRESSES      VARCHAR(128)         NULL,
   SENDERNAME           VARCHAR(128)         NULL,
   RECEIVERADDRESSES    TEXT                 NULL,
   RECEIVERNAMES        TEXT                 NULL,
   CCADDRESSES          TEXT                 NULL,
   BCCANAMES            TEXT                 NULL,
   BCCADDRESSES         TEXT                 NULL,
   CCNAMES              TEXT                 NULL,
   EMAILID              VARCHAR(128)         NULL,
   TYPES                NUMERIC(18,0)        NULL,
   USERID               NUMERIC(18,0)        NULL,
   ISREPLY              NUMERIC(18,0)        NULL,
   MAILDATE             DATETIME             NULL,
   FILEIDS              VARCHAR(512)         NULL,
   ISREAD               NUMERIC(18,0)        NULL,
   SETID                NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '外部邮件',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '自增列',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'MAILID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主题',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'TITLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '内容',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'CONTENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发件人地址',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'SENDERADDRESSES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发件人地址别名',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'SENDERNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '收件人地址',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'RECEIVERADDRESSES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '收件人地址别名',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'RECEIVERNAMES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '抄送人地址',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'CCADDRESSES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '暗送人地址别名',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'BCCANAMES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '暗送人地址',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'BCCADDRESSES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '抄送人地址别名',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'CCNAMES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '邮件ID',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'EMAILID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   ' 邮件类型 1:收件箱;2:发件箱;3:草稿箱;4:垃圾箱',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'TYPES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否回复',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'ISREPLY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '日期',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'MAILDATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '附件ID',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'FILEIDS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否已读',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'ISREAD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '邮箱ID',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL', 'column', 'SETID'
go

ALTER TABLE OUT_MAIL
   ADD CONSTRAINT PK_OUT_MAIL PRIMARY KEY NONCLUSTERED (MAILID)
go

CREATE TABLE OUT_MAIL_ATTACHMENT (
   FILEID               NUMERIC(18,0)        NOT NULL,
   FILENAME             VARCHAR(100)         NULL,
   FILEPATH             VARCHAR(100)         NULL,
   MAILID               NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '外部邮件附件',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_ATTACHMENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '文件ID',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_ATTACHMENT', 'column', 'FILEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '文件名',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_ATTACHMENT', 'column', 'FILENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '文件存放路径',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_ATTACHMENT', 'column', 'FILEPATH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '邮件ID',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_ATTACHMENT', 'column', 'MAILID'
go

ALTER TABLE OUT_MAIL_ATTACHMENT
   ADD CONSTRAINT PK_OUT_MAIL_ATTACHMENT PRIMARY KEY NONCLUSTERED (FILEID)
go

CREATE TABLE OUT_MAIL_LINKMAN (
   LINKID               NUMERIC(18,0)        NOT NULL,
   USERID               NUMERIC(18,0)        NULL,
   MAILID               NUMERIC(18,0)        NULL,
   SENDTIME             DATETIME             NULL,
   LINKNAME             VARCHAR(20)          NULL,
   LINKADDRESS          VARCHAR(2000)        NULL,
   SENDTIMES            NUMERIC(18,0)        NULL 
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '外部邮件最近联系',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_LINKMAN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_LINKMAN', 'column', 'LINKID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_LINKMAN', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '邮件ID',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_LINKMAN', 'column', 'MAILID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '送送时间',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_LINKMAN', 'column', 'SENDTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '联系人名称',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_LINKMAN', 'column', 'LINKNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '联系人地址',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_LINKMAN', 'column', 'LINKADDRESS'
go

ALTER TABLE OUT_MAIL_LINKMAN
   ADD CONSTRAINT PK_OUT_MAIL_LINKMAN PRIMARY KEY NONCLUSTERED (LINKID)
go

CREATE TABLE OUT_MAIL_USER_SETING (
   ID                   NUMERIC(18,0)        NOT NULL,
   USERID               NUMERIC(18,0)        NULL,
   USERNAME             VARCHAR(128)         NULL,
   MAILADDRESS          VARCHAR(128)         NULL,
   MAILPASS             VARCHAR(128)         NULL,
   SMTPHOST             VARCHAR(128)         NULL,
   SMTPPORT             VARCHAR(64)          NULL,
   POPHOST              VARCHAR(128)         NULL,
   POPPORT              VARCHAR(64)          NULL,
   IMAPHOST             VARCHAR(128)         NULL,
   IMAPPORT             VARCHAR(128)         NULL,
   ISDEFAULT            SMALLINT             NULL,
   MAILTYPE             VARCHAR(50)          NULL,
   USESSL               SMALLINT             NULL DEFAULT 0,
   ISDELETEREMOTE       SMALLINT             NULL DEFAULT 0,
   ISVALIDATE           SMALLINT             NULL DEFAULT 1,
   ISHANDLEATTACH       SMALLINT             NULL DEFAULT 1
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '外部邮件用户设置',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户名称',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'USERNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '外部邮箱地址',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'MAILADDRESS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '外部邮箱密码',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'MAILPASS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'smt主机',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'SMTPHOST'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'smt端口',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'SMTPPORT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'pop主机',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'POPHOST'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'pop端口',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'POPPORT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'imap主机',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'IMAPHOST'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'imap端口',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'IMAPPORT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否默认',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'ISDEFAULT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '接收邮件服务器类型',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'MAILTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否使用SSL连接服务器',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'USESSL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否删除远程邮件',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'ISDELETEREMOTE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否需要身份认证',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'ISVALIDATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否下载附件',
   'user', @CURRENTUSER, 'table', 'OUT_MAIL_USER_SETING', 'column', 'ISHANDLEATTACH'
go

ALTER TABLE OUT_MAIL_USER_SETING
   ADD CONSTRAINT PK_OUT_MAIL_USER_SETING PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_ACCEPT_IP (
   ACCEPTID             NUMERIC(18,0)        NOT NULL,
   TITLE                VARCHAR(128)         NULL,
   STARTIP              VARCHAR(20)          NULL,
   ENDIP                VARCHAR(20)          NULL,
   REMARK               VARCHAR(200)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'IP限制设置',
   'user', @CURRENTUSER, 'table', 'SYS_ACCEPT_IP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_ACCEPT_IP', 'column', 'ACCEPTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '名称',
   'user', @CURRENTUSER, 'table', 'SYS_ACCEPT_IP', 'column', 'TITLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '开始IP',
   'user', @CURRENTUSER, 'table', 'SYS_ACCEPT_IP', 'column', 'STARTIP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '结束IP',
   'user', @CURRENTUSER, 'table', 'SYS_ACCEPT_IP', 'column', 'ENDIP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'SYS_ACCEPT_IP', 'column', 'REMARK'
go

ALTER TABLE SYS_ACCEPT_IP
   ADD CONSTRAINT PK_SYS_ACCEPT_IP PRIMARY KEY NONCLUSTERED (ACCEPTID)
go

CREATE TABLE SYS_ALIAS_SCRIPT (
   ID                   NUMERIC(18,0)        NOT NULL,
   ALIAS_NAME           VARCHAR(100)         NULL,
   ALIAS_DESC           VARCHAR(100)         NULL,
   CLASS_NAME           VARCHAR(400)         NULL,
   CLASS_INS_NAME       VARCHAR(200)         NULL,
   METHOD_NAME          VARCHAR(200)         NULL,
   METHOD_DESC          VARCHAR(400)         NULL,
   SCRIPT_COMTEN        TEXT                 NULL,
   RETURN_TYPE          VARCHAR(50)          NULL,
   SCRIPT_TYPE          VARCHAR(50)          NULL,
   ARGUMENT             TEXT                 NULL,
   ENABLE               NUMERIC(2)           NULL,
   IS_RETURN_VALUE      NUMERIC(2)           NULL,
   RETURN_PARAM_JSON    VARCHAR(2000)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '自定义别名脚本表',
   'user', @CURRENTUSER, 'table', 'SYS_ALIAS_SCRIPT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '脚本的别名',
   'user', @CURRENTUSER, 'table', 'SYS_ALIAS_SCRIPT', 'column', 'ALIAS_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '脚本的描叙',
   'user', @CURRENTUSER, 'table', 'SYS_ALIAS_SCRIPT', 'column', 'ALIAS_DESC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '调用类的路径',
   'user', @CURRENTUSER, 'table', 'SYS_ALIAS_SCRIPT', 'column', 'CLASS_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '调用类的对象名',
   'user', @CURRENTUSER, 'table', 'SYS_ALIAS_SCRIPT', 'column', 'CLASS_INS_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '调用的方法名',
   'user', @CURRENTUSER, 'table', 'SYS_ALIAS_SCRIPT', 'column', 'METHOD_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '调用的方法的描叙',
   'user', @CURRENTUSER, 'table', 'SYS_ALIAS_SCRIPT', 'column', 'METHOD_DESC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '自定义脚本内容',
   'user', @CURRENTUSER, 'table', 'SYS_ALIAS_SCRIPT', 'column', 'SCRIPT_COMTEN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '方法返回类型',
   'user', @CURRENTUSER, 'table', 'SYS_ALIAS_SCRIPT', 'column', 'RETURN_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '自定义：custom  系统默认：default',
   'user', @CURRENTUSER, 'table', 'SYS_ALIAS_SCRIPT', 'column', 'SCRIPT_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '方法相关设置',
   'user', @CURRENTUSER, 'table', 'SYS_ALIAS_SCRIPT', 'column', 'ARGUMENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '禁用：1   启用：0',
   'user', @CURRENTUSER, 'table', 'SYS_ALIAS_SCRIPT', 'column', 'ENABLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否设置返回值格式：0：否；1：是',
   'user', @CURRENTUSER, 'table', 'SYS_ALIAS_SCRIPT', 'column', 'IS_RETURN_VALUE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '返回值格式设置',
   'user', @CURRENTUSER, 'table', 'SYS_ALIAS_SCRIPT', 'column', 'RETURN_PARAM_JSON'
go

ALTER TABLE SYS_ALIAS_SCRIPT
   ADD CONSTRAINT PK_SYS_ALIAS_SCRIPT PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_AUDIT (
   AUDITID              NUMERIC(18,0)        NOT NULL,
   OPNAME               VARCHAR(128)         NULL,
   EXETIME              DATETIME             NULL,
   EXECUTORID           NUMERIC(18,0)        NULL,
   EXECUTOR             VARCHAR(64)          NULL,
   FROMIP               VARCHAR(64)          NULL,
   EXEMETHOD            VARCHAR(128)         NULL,
   REQUESTURI           VARCHAR(256)         NULL,
   REQPARAMS            TEXT                 NULL,
   OWNERMODEL           VARCHAR(200)         NULL,
   EXECTYPE             VARCHAR(200)         NULL,
   ORGID                NUMERIC(18,0)        NULL,
   DETAIL               TEXT                 NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '系统审计',
   'user', @CURRENTUSER, 'table', 'SYS_AUDIT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '操作名称',
   'user', @CURRENTUSER, 'table', 'SYS_AUDIT', 'column', 'OPNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '执行时间',
   'user', @CURRENTUSER, 'table', 'SYS_AUDIT', 'column', 'EXETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '执行人ID',
   'user', @CURRENTUSER, 'table', 'SYS_AUDIT', 'column', 'EXECUTORID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '执行人',
   'user', @CURRENTUSER, 'table', 'SYS_AUDIT', 'column', 'EXECUTOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'IP',
   'user', @CURRENTUSER, 'table', 'SYS_AUDIT', 'column', 'FROMIP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '执行方法',
   'user', @CURRENTUSER, 'table', 'SYS_AUDIT', 'column', 'EXEMETHOD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '请求URL',
   'user', @CURRENTUSER, 'table', 'SYS_AUDIT', 'column', 'REQUESTURI'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '请求参数',
   'user', @CURRENTUSER, 'table', 'SYS_AUDIT', 'column', 'REQPARAMS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '归属模块',
   'user', @CURRENTUSER, 'table', 'SYS_AUDIT', 'column', 'OWNERMODEL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '日志类型',
   'user', @CURRENTUSER, 'table', 'SYS_AUDIT', 'column', 'EXECTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '归属组织',
   'user', @CURRENTUSER, 'table', 'SYS_AUDIT', 'column', 'ORGID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '明细信息',
   'user', @CURRENTUSER, 'table', 'SYS_AUDIT', 'column', 'DETAIL'
go

ALTER TABLE SYS_AUDIT
   ADD CONSTRAINT PK_SYS_AUDIT PRIMARY KEY NONCLUSTERED (AUDITID)
go

CREATE TABLE SYS_CALENDAR (
   ID                   NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(50)          NULL,
   MEMO                 VARCHAR(400)         NULL,
   ISDEFAULT            NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '系统日历',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '日历名称',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '描述',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '1=默认日历
   0=非默认',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR', 'column', 'ISDEFAULT'
go

ALTER TABLE SYS_CALENDAR
   ADD CONSTRAINT PK_SYS_CALENDAR PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_CALENDAR_ASSIGN (
   ID                   NUMERIC(18,0)        NOT NULL,
   CANLENDARID          NUMERIC(18,0)        NULL,
   ASSIGNTYPE           SMALLINT             NULL,
   ASSIGNID             NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '日历分配',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR_ASSIGN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR_ASSIGN', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '日历ID',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR_ASSIGN', 'column', 'CANLENDARID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分配者类型
   1,用户
   2.组织',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR_ASSIGN', 'column', 'ASSIGNTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分配者ID',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR_ASSIGN', 'column', 'ASSIGNID'
go

ALTER TABLE SYS_CALENDAR_ASSIGN
   ADD CONSTRAINT PK_SYS_CALENDAR_ASSIGN PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_CALENDAR_SETTING (
   ID                   NUMERIC(18,0)        NOT NULL,
   CALENDARID           NUMERIC(18,0)        NULL,
   YEARS                SMALLINT             NULL,
   MONTHS               SMALLINT             NULL,
   DAYS                 SMALLINT             NULL,
   TYPE                 SMALLINT             NULL,
   WORKTIMEID           NUMERIC(18,0)        NOT NULL,
   CALDAY               VARCHAR(20)          NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '日历设置',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR_SETTING'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR_SETTING', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '日历ID',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR_SETTING', 'column', 'CALENDARID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '年份',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR_SETTING', 'column', 'YEARS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '月份',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR_SETTING', 'column', 'MONTHS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '天数',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR_SETTING', 'column', 'DAYS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '上班类型
   1,上班
   2,休息',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR_SETTING', 'column', 'TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '班次ID',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR_SETTING', 'column', 'WORKTIMEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '当前日期',
   'user', @CURRENTUSER, 'table', 'SYS_CALENDAR_SETTING', 'column', 'CALDAY'
go

ALTER TABLE SYS_CALENDAR_SETTING
   ADD CONSTRAINT PK_SYS_CALENDAR_SETTING PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_CODE_TEMPLATE (
   ID                   NUMERIC(18,0)        NOT NULL,
   TEMPLATE_NAME        VARCHAR(200)         NULL,
   HTML                 TEXT                 NULL,
   MEMO                 VARCHAR(200)         NULL,
   TEMPLATE_ALIAS       VARCHAR(200)         NULL,
   TEMPLATE_TYPE        SMALLINT             NULL,
   ISSUBNEED            SMALLINT             NULL,
   FILENAME             VARCHAR(200)         NULL,
   FILEDIR              VARCHAR(200)         NULL,
   FORMEDIT             SMALLINT             NULL,
   FORMDETAIL           SMALLINT             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '基于自定义表的代码模版管理表',
   'user', @CURRENTUSER, 'table', 'SYS_CODE_TEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_CODE_TEMPLATE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版名称',
   'user', @CURRENTUSER, 'table', 'SYS_CODE_TEMPLATE', 'column', 'TEMPLATE_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版文件内容',
   'user', @CURRENTUSER, 'table', 'SYS_CODE_TEMPLATE', 'column', 'HTML'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版描述',
   'user', @CURRENTUSER, 'table', 'SYS_CODE_TEMPLATE', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版别名',
   'user', @CURRENTUSER, 'table', 'SYS_CODE_TEMPLATE', 'column', 'TEMPLATE_ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版类型1-系统模版，2自定义模版',
   'user', @CURRENTUSER, 'table', 'SYS_CODE_TEMPLATE', 'column', 'TEMPLATE_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '子表是否生成该模版文件0-不需要生成，1-生成 ，默认不生成',
   'user', @CURRENTUSER, 'table', 'SYS_CODE_TEMPLATE', 'column', 'ISSUBNEED'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '文件名',
   'user', @CURRENTUSER, 'table', 'SYS_CODE_TEMPLATE', 'column', 'FILENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '文件路径',
   'user', @CURRENTUSER, 'table', 'SYS_CODE_TEMPLATE', 'column', 'FILEDIR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单编辑标识',
   'user', @CURRENTUSER, 'table', 'SYS_CODE_TEMPLATE', 'column', 'FORMEDIT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单明细标识',
   'user', @CURRENTUSER, 'table', 'SYS_CODE_TEMPLATE', 'column', 'FORMDETAIL'
go

ALTER TABLE SYS_CODE_TEMPLATE
   ADD CONSTRAINT PK_SYS_CODE_TEMPLATE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_CONDITION_SCRIPT (
   ID                   NUMERIC(18,0)        NOT NULL,
   CLASS_NAME           VARCHAR(400)         NULL,
   CLASS_INS_NAME       VARCHAR(200)         NULL,
   METHOD_NAME          VARCHAR(200)         NULL,
   METHOD_DESC          VARCHAR(400)         NULL,
   RETURN_TYPE          VARCHAR(50)          NULL,
   ARGUMENT             TEXT                 NULL,
   ENABLE               SMALLINT             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '条件脚本',
   'user', @CURRENTUSER, 'table', 'SYS_CONDITION_SCRIPT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_CONDITION_SCRIPT', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '脚本所在类的类名',
   'user', @CURRENTUSER, 'table', 'SYS_CONDITION_SCRIPT', 'column', 'CLASS_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '类实例名',
   'user', @CURRENTUSER, 'table', 'SYS_CONDITION_SCRIPT', 'column', 'CLASS_INS_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '方法名',
   'user', @CURRENTUSER, 'table', 'SYS_CONDITION_SCRIPT', 'column', 'METHOD_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '方法描述',
   'user', @CURRENTUSER, 'table', 'SYS_CONDITION_SCRIPT', 'column', 'METHOD_DESC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '返回值类型',
   'user', @CURRENTUSER, 'table', 'SYS_CONDITION_SCRIPT', 'column', 'RETURN_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '参数信息',
   'user', @CURRENTUSER, 'table', 'SYS_CONDITION_SCRIPT', 'column', 'ARGUMENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否有效',
   'user', @CURRENTUSER, 'table', 'SYS_CONDITION_SCRIPT', 'column', 'ENABLE'
go

ALTER TABLE SYS_CONDITION_SCRIPT
   ADD CONSTRAINT PK_SYS_CONDITION_SCRIPT PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_DATASOURCE (
   ID                   NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(50)          NULL,
   ALIAS                VARCHAR(20)          NULL,
   DRIVERNAME           VARCHAR(100)         NULL,
   URL                  VARCHAR(100)         NULL,
   USERNAME             VARCHAR(20)          NULL,
   PASSWORD             VARCHAR(20)          NULL,
   DBTYPE               VARCHAR(20)          NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '系统数据源管理',
   'user', @CURRENTUSER, 'table', 'SYS_DATASOURCE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_DATASOURCE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据源名称',
   'user', @CURRENTUSER, 'table', 'SYS_DATASOURCE', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '别名',
   'user', @CURRENTUSER, 'table', 'SYS_DATASOURCE', 'column', 'ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '驱动名称',
   'user', @CURRENTUSER, 'table', 'SYS_DATASOURCE', 'column', 'DRIVERNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据库URL',
   'user', @CURRENTUSER, 'table', 'SYS_DATASOURCE', 'column', 'URL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户名',
   'user', @CURRENTUSER, 'table', 'SYS_DATASOURCE', 'column', 'USERNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '密码',
   'user', @CURRENTUSER, 'table', 'SYS_DATASOURCE', 'column', 'PASSWORD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据库类型',
   'user', @CURRENTUSER, 'table', 'SYS_DATASOURCE', 'column', 'DBTYPE'
go

ALTER TABLE SYS_DATASOURCE
   ADD CONSTRAINT PK_SYS_DATASOURCE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_DB_ID (
   ID                   SMALLINT             NOT NULL,
   INCREMENTAL          NUMERIC(18,0)        NULL,
   BOUND                NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '系统ID生成表',
   'user', @CURRENTUSER, 'table', 'SYS_DB_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '计算机编号',
   'user', @CURRENTUSER, 'table', 'SYS_DB_ID', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'ID增量',
   'user', @CURRENTUSER, 'table', 'SYS_DB_ID', 'column', 'INCREMENTAL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '边界值',
   'user', @CURRENTUSER, 'table', 'SYS_DB_ID', 'column', 'BOUND'
go

ALTER TABLE SYS_DB_ID
   ADD CONSTRAINT PK_SYS_DB_ID PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_DEMENSION (
   DEMID                NUMERIC(18,0)        NOT NULL,
   DEMNAME              VARCHAR(128)         NOT NULL,
   DEMDESC              VARCHAR(1024)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '人员维度表',
   'user', @CURRENTUSER, 'table', 'SYS_DEMENSION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '维度编号',
   'user', @CURRENTUSER, 'table', 'SYS_DEMENSION', 'column', 'DEMID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '维度名称',
   'user', @CURRENTUSER, 'table', 'SYS_DEMENSION', 'column', 'DEMNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '维度描述',
   'user', @CURRENTUSER, 'table', 'SYS_DEMENSION', 'column', 'DEMDESC'
go

ALTER TABLE SYS_DEMENSION
   ADD CONSTRAINT PK_SYS_DEMENSION PRIMARY KEY NONCLUSTERED (DEMID)
go


CREATE TABLE SYS_DIC (
   DICID                NUMERIC(18,0)        NOT NULL,
   TYPEID               NUMERIC(18,0)        NULL,
   ITEMKEY              VARCHAR(64)          NULL,
   ITEMNAME             VARCHAR(64)          NOT NULL,
   ITEMVALUE            VARCHAR(128)         NOT NULL,
   DESCP                VARCHAR(256)         NULL,
   SN                   NUMERIC(18,0)        NULL,
   NODEPATH             VARCHAR(100)         NULL,
   PARENTID             NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据字典',
   'user', @CURRENTUSER, 'table', 'SYS_DIC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_DIC', 'column', 'DICID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分类ID',
   'user', @CURRENTUSER, 'table', 'SYS_DIC', 'column', 'TYPEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '项Key',
   'user', @CURRENTUSER, 'table', 'SYS_DIC', 'column', 'ITEMKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '项名',
   'user', @CURRENTUSER, 'table', 'SYS_DIC', 'column', 'ITEMNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '项值',
   'user', @CURRENTUSER, 'table', 'SYS_DIC', 'column', 'ITEMVALUE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '描述',
   'user', @CURRENTUSER, 'table', 'SYS_DIC', 'column', 'DESCP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '序号',
   'user', @CURRENTUSER, 'table', 'SYS_DIC', 'column', 'SN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '路径',
   'user', @CURRENTUSER, 'table', 'SYS_DIC', 'column', 'NODEPATH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '父id',
   'user', @CURRENTUSER, 'table', 'SYS_DIC', 'column', 'PARENTID'
go

ALTER TABLE SYS_DIC
   ADD CONSTRAINT PK_SYS_DIC PRIMARY KEY NONCLUSTERED (DICID)
go

CREATE TABLE SYS_ERROR_LOG (
   ID                   NUMERIC(18,0)        NOT NULL,
   HASHCODE             VARCHAR(40)          NULL,
   ACCOUNT              VARCHAR(50)          NULL,
   IP                   VARCHAR(30)          NULL,
   ERRORURL             VARCHAR(2000)        NULL,
   ERROR                TEXT                 NULL,
   ERRORDATE            DATETIME             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '错误日志表',
   'user', @CURRENTUSER, 'table', 'SYS_ERROR_LOG'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_ERROR_LOG', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '错误哈希码',
   'user', @CURRENTUSER, 'table', 'SYS_ERROR_LOG', 'column', 'HASHCODE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '帐号',
   'user', @CURRENTUSER, 'table', 'SYS_ERROR_LOG', 'column', 'ACCOUNT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'ip',
   'user', @CURRENTUSER, 'table', 'SYS_ERROR_LOG', 'column', 'IP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '错误地址',
   'user', @CURRENTUSER, 'table', 'SYS_ERROR_LOG', 'column', 'ERRORURL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '错误详细信息',
   'user', @CURRENTUSER, 'table', 'SYS_ERROR_LOG', 'column', 'ERROR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '时间',
   'user', @CURRENTUSER, 'table', 'SYS_ERROR_LOG', 'column', 'ERRORDATE'
go

ALTER TABLE SYS_ERROR_LOG
   ADD CONSTRAINT PK_SYS_ERROR_LOG PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_EXCEL_IMPRULE (
   ID                   NUMERIC(18,0)        NOT NULL,
   TABLE_NAME           VARCHAR(30)          NULL,
   COLUMN_STR           VARCHAR(200)         NULL,
   MARK                 VARCHAR(200)         NULL,
   IMP_TYPE             SMALLINT             NULL,
   BUSI_DATE            DATETIME             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'excel导入规则表',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_IMPRULE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_IMPRULE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表名称',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_IMPRULE', 'column', 'TABLE_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '要填充的字段串逗号分隔',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_IMPRULE', 'column', 'COLUMN_STR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_IMPRULE', 'column', 'MARK'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '0导入现有表,1导入并生成表',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_IMPRULE', 'column', 'IMP_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '操作日期',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_IMPRULE', 'column', 'BUSI_DATE'
go

ALTER TABLE SYS_EXCEL_IMPRULE
   ADD CONSTRAINT PK_SYS_EXCEL_IMPRULE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_FILE (
   FILEID               NUMERIC(18,0)        NOT NULL,
   TYPEID               NUMERIC(18,0)        NULL,
   FILENAME             VARCHAR(128)         NOT NULL,
   FILEPATH             VARCHAR(128)         NOT NULL,
   CREATETIME           DATETIME             NOT NULL,
   EXT                  VARCHAR(32)          NULL,
   FILETYPE             VARCHAR(32)          NOT NULL,
   NOTE                 VARCHAR(1024)        NULL,
   CREATORID            NUMERIC(18,0)        NULL,
   CREATOR              VARCHAR(32)          NOT NULL,
   TOTALBYTES           NUMERIC(18,0)        NULL DEFAULT 0,
   DELFLAG              SMALLINT             NULL,
   FILEBLOB             IMAGE                NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '附件',
   'user', @CURRENTUSER, 'table', 'SYS_FILE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_FILE', 'column', 'FILEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分类ID',
   'user', @CURRENTUSER, 'table', 'SYS_FILE', 'column', 'TYPEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '文件名',
   'user', @CURRENTUSER, 'table', 'SYS_FILE', 'column', 'FILENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '文件路径',
   'user', @CURRENTUSER, 'table', 'SYS_FILE', 'column', 'FILEPATH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'SYS_FILE', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '扩展名',
   'user', @CURRENTUSER, 'table', 'SYS_FILE', 'column', 'EXT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '附件类型
   如：邮件附件',
   'user', @CURRENTUSER, 'table', 'SYS_FILE', 'column', 'FILETYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '说明',
   'user', @CURRENTUSER, 'table', 'SYS_FILE', 'column', 'NOTE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '上传者ID',
   'user', @CURRENTUSER, 'table', 'SYS_FILE', 'column', 'CREATORID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '上传者',
   'user', @CURRENTUSER, 'table', 'SYS_FILE', 'column', 'CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '总字节数',
   'user', @CURRENTUSER, 'table', 'SYS_FILE', 'column', 'TOTALBYTES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '1=已删除
   0=删除',
   'user', @CURRENTUSER, 'table', 'SYS_FILE', 'column', 'DELFLAG'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '附件内容',
   'user', @CURRENTUSER, 'table', 'SYS_FILE', 'column', 'FILEBLOB'
go

ALTER TABLE SYS_FILE
   ADD CONSTRAINT PK_SYS_FILE PRIMARY KEY NONCLUSTERED (FILEID)
go

CREATE TABLE SYS_GL_TYPE (
   TYPEID               NUMERIC(18,0)        NOT NULL,
   TYPENAME             VARCHAR(128)         NOT NULL,
   NODEPATH             VARCHAR(200)         NULL,
   DEPTH                NUMERIC(18,0)        NOT NULL,
   PARENTID             NUMERIC(18,0)        NULL,
   CATKEY               VARCHAR(64)          NULL,
   NODEKEY              VARCHAR(64)          NOT NULL,
   SN                   NUMERIC(18,0)        NOT NULL,
   USERID               NUMERIC(18,0)        NULL,
   DEPID                NUMERIC(18,0)        NULL,
   TYPE                 NUMERIC(18,0)        NULL,
   ISLEAF               SMALLINT             NULL,
   NODECODE             VARCHAR(20)          NULL,
   NODECODETYPE         SMALLINT             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '总分类表
   用于显示树层次结构的分类
   可以允许任何层次结构',
   'user', @CURRENTUSER, 'table', 'SYS_GL_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分类ID',
   'user', @CURRENTUSER, 'table', 'SYS_GL_TYPE', 'column', 'TYPEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分类名称',
   'user', @CURRENTUSER, 'table', 'SYS_GL_TYPE', 'column', 'TYPENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '路径',
   'user', @CURRENTUSER, 'table', 'SYS_GL_TYPE', 'column', 'NODEPATH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '层次',
   'user', @CURRENTUSER, 'table', 'SYS_GL_TYPE', 'column', 'DEPTH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '父节点',
   'user', @CURRENTUSER, 'table', 'SYS_GL_TYPE', 'column', 'PARENTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分类Key',
   'user', @CURRENTUSER, 'table', 'SYS_GL_TYPE', 'column', 'CATKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点的分类Key',
   'user', @CURRENTUSER, 'table', 'SYS_GL_TYPE', 'column', 'NODEKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '序号',
   'user', @CURRENTUSER, 'table', 'SYS_GL_TYPE', 'column', 'SN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '所属用户
   当为空则代表为公共分类',
   'user', @CURRENTUSER, 'table', 'SYS_GL_TYPE', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '所属部门',
   'user', @CURRENTUSER, 'table', 'SYS_GL_TYPE', 'column', 'DEPID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '类型
   (0平铺
   ,1树形)',
   'user', @CURRENTUSER, 'table', 'SYS_GL_TYPE', 'column', 'TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否叶结点
   1=是
   0=否',
   'user', @CURRENTUSER, 'table', 'SYS_GL_TYPE', 'column', 'ISLEAF'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '子编码',
   'user', @CURRENTUSER, 'table', 'SYS_GL_TYPE', 'column', 'NODECODE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '子编码类型：0手工录入，1自动生成',
   'user', @CURRENTUSER, 'table', 'SYS_GL_TYPE', 'column', 'NODECODETYPE'
go

ALTER TABLE SYS_GL_TYPE
   ADD CONSTRAINT PK_SYS_GL_TYPE PRIMARY KEY NONCLUSTERED (TYPEID)
go

CREATE TABLE SYS_IDENTITY (
   ID                   NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(50)          NULL,
   ALIAS                VARCHAR(20)          NULL,
   REGULATION           VARCHAR(100)         NULL,
   GENTYPE              SMALLINT             NULL,
   NOLENGTH             NUMERIC(18,0)        NULL,
   CURDATE              VARCHAR(10)          NULL,
   INITVALUE            NUMERIC(18,0)        NULL,
   CURVALUE             NUMERIC(18,0)        NULL,
   STEP                 SMALLINT             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流水号生成',
   'user', @CURRENTUSER, 'table', 'SYS_IDENTITY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_IDENTITY', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '名称',
   'user', @CURRENTUSER, 'table', 'SYS_IDENTITY', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '别名',
   'user', @CURRENTUSER, 'table', 'SYS_IDENTITY', 'column', 'ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '规则',
   'user', @CURRENTUSER, 'table', 'SYS_IDENTITY', 'column', 'REGULATION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '每天生成',
   'user', @CURRENTUSER, 'table', 'SYS_IDENTITY', 'column', 'GENTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流水号长度',
   'user', @CURRENTUSER, 'table', 'SYS_IDENTITY', 'column', 'NOLENGTH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '当前日期',
   'user', @CURRENTUSER, 'table', 'SYS_IDENTITY', 'column', 'CURDATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '初始值',
   'user', @CURRENTUSER, 'table', 'SYS_IDENTITY', 'column', 'INITVALUE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '当前值',
   'user', @CURRENTUSER, 'table', 'SYS_IDENTITY', 'column', 'CURVALUE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '步长',
   'user', @CURRENTUSER, 'table', 'SYS_IDENTITY', 'column', 'STEP'
go

ALTER TABLE SYS_IDENTITY
   ADD CONSTRAINT PK_SYS_IDENTITY PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_JOB (
   JOBID                NUMERIC(18,0)        NOT NULL,
   JOBNAME              VARCHAR(100)         NULL,
   JOBCODE              VARCHAR(100)         NULL,
   JOBDESC              VARCHAR(400)         NULL,
   SETID                NUMERIC(18,0)        NULL DEFAULT 0,
   ISDELETE             NUMERIC(18,0)        NULL DEFAULT 0,
   GRADE                NUMERIC(10,0)        NULL DEFAULT 0
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '职务表',
   'user', @CURRENTUSER, 'table', 'SYS_JOB'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '职务ID',
   'user', @CURRENTUSER, 'table', 'SYS_JOB', 'column', 'JOBID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '职务名称',
   'user', @CURRENTUSER, 'table', 'SYS_JOB', 'column', 'JOBNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '职务代码',
   'user', @CURRENTUSER, 'table', 'SYS_JOB', 'column', 'JOBCODE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '职务描述',
   'user', @CURRENTUSER, 'table', 'SYS_JOB', 'column', 'JOBDESC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '设置码',
   'user', @CURRENTUSER, 'table', 'SYS_JOB', 'column', 'SETID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否删除',
   'user', @CURRENTUSER, 'table', 'SYS_JOB', 'column', 'ISDELETE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '等级',
   'user', @CURRENTUSER, 'table', 'SYS_JOB', 'column', 'GRADE'
go

ALTER TABLE SYS_JOB
   ADD CONSTRAINT PK_SYS_JOB PRIMARY KEY NONCLUSTERED (JOBID)
go



CREATE TABLE SYS_JOBLOG (
   LOGID                NUMERIC(18,0)        NOT NULL,
   JOBNAME              VARCHAR(50)          NULL,
   TRIGNAME             VARCHAR(50)          NULL,
   STARTTIME            DATETIME             NULL,
   ENDTIME              DATETIME             NULL,
   CONTENT              TEXT                 NULL,
   STATE                NUMERIC(18,0)        NULL,
   RUNTIME              NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '后台任务执行日志',
   'user', @CURRENTUSER, 'table', 'SYS_JOBLOG'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_JOBLOG', 'column', 'LOGID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '执行名称',
   'user', @CURRENTUSER, 'table', 'SYS_JOBLOG', 'column', 'JOBNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '触发名称',
   'user', @CURRENTUSER, 'table', 'SYS_JOBLOG', 'column', 'TRIGNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '开始时间',
   'user', @CURRENTUSER, 'table', 'SYS_JOBLOG', 'column', 'STARTTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '结束时间',
   'user', @CURRENTUSER, 'table', 'SYS_JOBLOG', 'column', 'ENDTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '日志内容',
   'user', @CURRENTUSER, 'table', 'SYS_JOBLOG', 'column', 'CONTENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '状态',
   'user', @CURRENTUSER, 'table', 'SYS_JOBLOG', 'column', 'STATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '运行时间持续时间',
   'user', @CURRENTUSER, 'table', 'SYS_JOBLOG', 'column', 'RUNTIME'
go

ALTER TABLE SYS_JOBLOG
   ADD CONSTRAINT PK_SYS_JOBLOG PRIMARY KEY NONCLUSTERED (LOGID)
go

CREATE TABLE SYS_LOG_SWITCH (
   ID                   NUMERIC(18,0)        NOT NULL,
   MODEL                VARCHAR(50)          NULL,
   STATUS               SMALLINT             NULL,
   CREATETIME           DATETIME             NULL,
   CREATOR              VARCHAR(20)          NULL,
   CREATORID            NUMERIC(18,0)        NULL,
   UPDBY                VARCHAR(20)          NULL,
   UPDBYID              NUMERIC(18,0)        NULL,
   MEMO                 VARCHAR(300)         NULL,
   LASTUPTIME           DATETIME             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '日志开关',
   'user', @CURRENTUSER, 'table', 'SYS_LOG_SWITCH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_LOG_SWITCH', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模块名',
   'user', @CURRENTUSER, 'table', 'SYS_LOG_SWITCH', 'column', 'MODEL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '状态',
   'user', @CURRENTUSER, 'table', 'SYS_LOG_SWITCH', 'column', 'STATUS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'SYS_LOG_SWITCH', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'SYS_LOG_SWITCH', 'column', 'CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人ID',
   'user', @CURRENTUSER, 'table', 'SYS_LOG_SWITCH', 'column', 'CREATORID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '更新人',
   'user', @CURRENTUSER, 'table', 'SYS_LOG_SWITCH', 'column', 'UPDBY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '更新人ID',
   'user', @CURRENTUSER, 'table', 'SYS_LOG_SWITCH', 'column', 'UPDBYID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'SYS_LOG_SWITCH', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '最后更新时间',
   'user', @CURRENTUSER, 'table', 'SYS_LOG_SWITCH', 'column', 'LASTUPTIME'
go

ALTER TABLE SYS_LOG_SWITCH
   ADD CONSTRAINT PK_SYS_LOG_SWITCH PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_MESSAGE_LOG (
   ID                   NUMERIC(18,0)        NOT NULL,
   SUBJECT              VARCHAR(100)         NULL,
   SENDTIME             DATETIME             NULL,
   RECEIVER             VARCHAR(1000)        NULL,
   MESSAGETYPE          NUMERIC(18,0)        NULL,
   STATE                NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '消息日志',
   'user', @CURRENTUSER, 'table', 'SYS_MESSAGE_LOG'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_MESSAGE_LOG', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主题',
   'user', @CURRENTUSER, 'table', 'SYS_MESSAGE_LOG', 'column', 'SUBJECT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发送时间',
   'user', @CURRENTUSER, 'table', 'SYS_MESSAGE_LOG', 'column', 'SENDTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '接收者 （多个人用，分隔）',
   'user', @CURRENTUSER, 'table', 'SYS_MESSAGE_LOG', 'column', 'RECEIVER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '消息类型
   1;邮件信息
   2;手机短信
   3;内部消息',
   'user', @CURRENTUSER, 'table', 'SYS_MESSAGE_LOG', 'column', 'MESSAGETYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发送状态 
   1:成功
   0:不成功',
   'user', @CURRENTUSER, 'table', 'SYS_MESSAGE_LOG', 'column', 'STATE'
go

ALTER TABLE SYS_MESSAGE_LOG
   ADD CONSTRAINT PK_SYS_MESSAGE_LOG PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_MSG_READ (
   ID                   NUMERIC(18,0)        NOT NULL,
   MESSAGEID            NUMERIC(18,0)        NULL,
   RECEIVERID           NUMERIC(18,0)        NULL,
   RECEIVER             VARCHAR(20)          NULL,
   RECEIVETIME          DATETIME             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '接收状态',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_READ'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_READ', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '消息ID',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_READ', 'column', 'MESSAGEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '接收人Id',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_READ', 'column', 'RECEIVERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '接收人',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_READ', 'column', 'RECEIVER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '接收时间',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_READ', 'column', 'RECEIVETIME'
go

ALTER TABLE SYS_MSG_READ
   ADD CONSTRAINT PK_SYS_MSG_READ PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_MSG_RECEIVER (
   ID                   NUMERIC(18,0)        NOT NULL,
   MESSAGEID            NUMERIC(18,0)        NULL,
   RECEIVETYPE          SMALLINT             NULL,
   RECEIVERID           NUMERIC(18,0)        NULL,
   RECEIVER             VARCHAR(20)          NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '消息接收者',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_RECEIVER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_RECEIVER', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '消息ID',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_RECEIVER', 'column', 'MESSAGEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '接收者类型',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_RECEIVER', 'column', 'RECEIVETYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '接收人ID
   0,接收人
   1,组织架构',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_RECEIVER', 'column', 'RECEIVERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '接收人',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_RECEIVER', 'column', 'RECEIVER'
go

ALTER TABLE SYS_MSG_RECEIVER
   ADD CONSTRAINT PK_SYS_MSG_RECEIVER PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_MSG_REPLY (
   ID                   NUMERIC(18,0)        NOT NULL,
   MESSAGEID            NUMERIC(18,0)        NULL,
   CONTENT              TEXT                 NULL,
   REPLYID              NUMERIC(18,0)        NULL,
   REPLY                VARCHAR(20)          NULL,
   REPLYTIME            DATETIME             NULL,
   ISPRIVATE            SMALLINT             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '消息回复',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_REPLY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_REPLY', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '消息id',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_REPLY', 'column', 'MESSAGEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '内容',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_REPLY', 'column', 'CONTENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '回复人ID',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_REPLY', 'column', 'REPLYID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '回复人',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_REPLY', 'column', 'REPLY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '回复时间',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_REPLY', 'column', 'REPLYTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '私密回复',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_REPLY', 'column', 'ISPRIVATE'
go

ALTER TABLE SYS_MSG_REPLY
   ADD CONSTRAINT PK_SYS_MSG_REPLY PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_MSG_SEND (
   ID                   NUMERIC(18,0)        NOT NULL,
   SUBJECT              VARCHAR(100)         NULL,
   USERID               NUMERIC(18,0)        NULL,
   USERNAME             VARCHAR(20)          NULL,
   MESSAGETYPE          VARCHAR(50)          NULL,
   CONTENT              TEXT                 NULL,
   SENDTIME             DATETIME             NULL,
   CANREPLY             SMALLINT             NULL,
   RECEIVERNAME         TEXT                 NULL,
   ATTACHMENT           VARCHAR(2000)        NULL
) 
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发送消息',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_SEND'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_SEND', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '标题',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_SEND', 'column', 'SUBJECT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发送人ID',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_SEND', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发送人',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_SEND', 'column', 'USERNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '消息类型(使用数据字典）',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_SEND', 'column', 'MESSAGETYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '内容',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_SEND', 'column', 'CONTENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发送时间',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_SEND', 'column', 'SENDTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '不需回复',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_SEND', 'column', 'CANREPLY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '接收人名',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_SEND', 'column', 'RECEIVERNAME'
go

ALTER TABLE SYS_MSG_SEND
   ADD CONSTRAINT PK_SYS_MSG_SEND PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_OFFICE_TEMPLATE (
   ID                   NUMERIC(18,0)        NOT NULL,
   SUBJECT              VARCHAR(20)          NULL,
   TEMPLATETYPE         NUMERIC(18,0)        NULL,
   MEMO                 VARCHAR(200)         NULL,
   CREATORID            NUMERIC(18,0)        NULL,
   CREATOR              VARCHAR(20)          NULL,
   CREATETIME           DATETIME             NULL,
   PATH                 VARCHAR(200)         NULL,
   TEMPLATEBLOB         IMAGE                NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'office模版',
   'user', @CURRENTUSER, 'table', 'SYS_OFFICE_TEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_OFFICE_TEMPLATE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主题',
   'user', @CURRENTUSER, 'table', 'SYS_OFFICE_TEMPLATE', 'column', 'SUBJECT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版类型',
   'user', @CURRENTUSER, 'table', 'SYS_OFFICE_TEMPLATE', 'column', 'TEMPLATETYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'SYS_OFFICE_TEMPLATE', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人ID',
   'user', @CURRENTUSER, 'table', 'SYS_OFFICE_TEMPLATE', 'column', 'CREATORID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'SYS_OFFICE_TEMPLATE', 'column', 'CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'SYS_OFFICE_TEMPLATE', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '路径',
   'user', @CURRENTUSER, 'table', 'SYS_OFFICE_TEMPLATE', 'column', 'PATH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模板内容',
   'user', @CURRENTUSER, 'table', 'SYS_OFFICE_TEMPLATE', 'column', 'TEMPLATEBLOB'
go

ALTER TABLE SYS_OFFICE_TEMPLATE
   ADD CONSTRAINT PK_SYS_OFFICE_TEMPLATE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_ORG (
   ORGID                NUMERIC(18,0)        NOT NULL,
   DEMID                NUMERIC(18,0)        NULL,
   ORGNAME              VARCHAR(128)         NOT NULL,
   ORGDESC              VARCHAR(500)         NULL,
   ORGSUPID             NUMERIC(18,0)        NULL,
   PATH                 VARCHAR(128)         NULL,
   DEPTH                NUMERIC(18,0)        NULL,
   ORGTYPE              NUMERIC(18,0)        NULL,
   CREATORID            NUMERIC(18,0)        NULL,
   CREATETIME           DATETIME             NULL,
   UPDATEID             NUMERIC(18,0)        NULL,
   UPDATETIME           DATETIME             NULL,
   SN                   NUMERIC(18,0)        NULL,
   FROMTYPE             SMALLINT             NULL,
   ORGPATHNAME          VARCHAR(2000)        NULL,
   ISDELETE             INT                  NULL DEFAULT 0,
   CODE              VARCHAR(128)         NOT NULL,
   COMPANYID            NUMERIC(18,0)        NULL,
   COMPANY              VARCHAR(20)          NULL,
   ORGSTAFF             SMALLINT             NULL,
   ORGCODE				VARCHAR(200)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织架构
   SYS_ORG',
   'user', @CURRENTUSER, 'table', 'SYS_ORG'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织ID',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'ORGID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '维度编号',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'DEMID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '名称',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'ORGNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '描述',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'ORGDESC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '上级',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'ORGSUPID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '路径',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'PATH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '层次',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'DEPTH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '类型
   0=集团
   1=公司
   2=部门
   3=其他组织',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'ORGTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '建立人',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'CREATORID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '建立时间',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '修改人',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'UPDATEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '修改时间',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'UPDATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '序号',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'SN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据来源',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'FROMTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织名称路径',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'ORGPATHNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否删除',
   'user', @CURRENTUSER, 'table', 'SYS_ORG', 'column', 'ISDELETE'
go

ALTER TABLE SYS_ORG
   ADD CONSTRAINT PK_SYS_ORG PRIMARY KEY NONCLUSTERED (ORGID)
go

CREATE TABLE SYS_ORG_PARAM (
   VALUEID              NUMERIC(18,0)        NULL,
   ORGID                NUMERIC(18,0)        NULL,
   PARAMID              NUMERIC(18,0)        NULL,
   PARAMVALUE           VARCHAR(200)         NULL,
   PARAMDATEVALUE       DATETIME             NULL,
   PARAMINTVALUE        NUMERIC(18,2)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织参数值',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_PARAM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键ID',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_PARAM', 'column', 'VALUEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织ID',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_PARAM', 'column', 'ORGID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '属性ID',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_PARAM', 'column', 'PARAMID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '字符串属性值',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_PARAM', 'column', 'PARAMVALUE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '日期型属性值',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_PARAM', 'column', 'PARAMDATEVALUE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数值型属性值',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_PARAM', 'column', 'PARAMINTVALUE'
go

CREATE TABLE SYS_ORG_ROLE (
   ID                   NUMERIC(18,0)        NOT NULL,
   ORGID                NUMERIC(18,0)        NULL,
   ROLEID               NUMERIC(18,0)        NULL,
   CANDEL               SMALLINT             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织和角色授权',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_ROLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_ROLE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织ID',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_ROLE', 'column', 'ORGID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '角色ID',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_ROLE', 'column', 'ROLEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否可以删除(在组织授权的不可以删除0,不可以删除,1,可以删除)',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_ROLE', 'column', 'CANDEL'
go

ALTER TABLE SYS_ORG_ROLE
   ADD CONSTRAINT PK_SYS_ORG_ROLE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_ORG_ROLEMANAGE (
   ID                   NUMERIC(18,0)        NOT NULL,
   ORGID                NUMERIC(18,0)        NULL,
   ROLEID               NUMERIC(18,0)        NULL,
   CANDEL               SMALLINT             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织可以授权的角色范围(用于分级授权)',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_ROLEMANAGE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_ROLEMANAGE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织ID',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_ROLEMANAGE', 'column', 'ORGID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '角色',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_ROLEMANAGE', 'column', 'ROLEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否可删除',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_ROLEMANAGE', 'column', 'CANDEL'
go

ALTER TABLE SYS_ORG_ROLEMANAGE
   ADD CONSTRAINT PK_SYS_ORG_ROLEMANAGE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_ORG_TYPE (
   ID                   NUMERIC(18,0)        NOT NULL,
   DEMID                NUMERIC(18,0)        NULL,
   NAME                 VARCHAR(50)          NULL,
   LEVELS               SMALLINT             NULL,
   MEMO                 VARCHAR(100)         NULL,
   ICON                 VARCHAR(100)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织结构类型',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_TYPE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '维度ID',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_TYPE', 'column', 'DEMID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '名称',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_TYPE', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '级别',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_TYPE', 'column', 'LEVELS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_TYPE', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '显示小图片',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_TYPE', 'column', 'ICON'
go

ALTER TABLE SYS_ORG_TYPE
   ADD CONSTRAINT PK_SYS_ORG_TYPE PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_OVERTIME (
   ID                   NUMERIC(18,0)        NOT NULL,
   SUBJECT              VARCHAR(50)          NULL,
   USERID               NUMERIC(18,0)        NULL,
   STARTTIME            DATETIME             NULL,
   ENDTIME              DATETIME             NULL,
   WORKTYPE             SMALLINT             NULL,
   MEMO                 VARCHAR(200)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '加班情况',
   'user', @CURRENTUSER, 'table', 'SYS_OVERTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_OVERTIME', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主题',
   'user', @CURRENTUSER, 'table', 'SYS_OVERTIME', 'column', 'SUBJECT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'SYS_OVERTIME', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '开始时间',
   'user', @CURRENTUSER, 'table', 'SYS_OVERTIME', 'column', 'STARTTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '结束时间',
   'user', @CURRENTUSER, 'table', 'SYS_OVERTIME', 'column', 'ENDTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '类型
   1.加班
   2.请假',
   'user', @CURRENTUSER, 'table', 'SYS_OVERTIME', 'column', 'WORKTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'SYS_OVERTIME', 'column', 'MEMO'
go

ALTER TABLE SYS_OVERTIME
   ADD CONSTRAINT PK_SYS_OVERTIME PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_PARAM (
   PARAMID              NUMERIC(18,0)        NOT NULL,
   PARAMKEY             VARCHAR(32)          NULL,
   PARAMNAME            VARCHAR(50)          NULL,
   DATATYPE             VARCHAR(20)          NULL,
   EFFECT               SMALLINT             NULL,
   BELONGDEM            NUMERIC(20,0)        NULL,
   SOURCETYPE           VARCHAR(20)          NULL,
   SOURCEKEY            VARCHAR(100)         NULL,
   DESCRIPTION          VARCHAR(256)         NULL,
   STATUS_              SMALLINT             NULL,
   CATEGORY             VARCHAR(256)         NULL,
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户或组织自定义属性',
   'user', @CURRENTUSER, 'table', 'SYS_PARAM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_PARAM', 'column', 'PARAMID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '属性key值',
   'user', @CURRENTUSER, 'table', 'SYS_PARAM', 'column', 'PARAMKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '属性名称',
   'user', @CURRENTUSER, 'table', 'SYS_PARAM', 'column', 'PARAMNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据类型',
   'user', @CURRENTUSER, 'table', 'SYS_PARAM', 'column', 'DATATYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '参数类型
   1.个人
   2.组织',
   'user', @CURRENTUSER, 'table', 'SYS_PARAM', 'column', 'EFFECT'
go

ALTER TABLE SYS_PARAM
   ADD CONSTRAINT PK_SYS_PARAM PRIMARY KEY NONCLUSTERED (PARAMID)
go

CREATE TABLE SYS_PAUR (
   PAURID               NUMERIC(18,0)        NOT NULL,
   PAURNAME             VARCHAR(30)          NULL,
   ALIASNAME            VARCHAR(30)          NULL,
   PAURVALUE            VARCHAR(50)          NULL,
   USERID               NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '皮肤设置',
   'user', @CURRENTUSER, 'table', 'SYS_PAUR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_PAUR', 'column', 'PAURID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '名称',
   'user', @CURRENTUSER, 'table', 'SYS_PAUR', 'column', 'PAURNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '别名',
   'user', @CURRENTUSER, 'table', 'SYS_PAUR', 'column', 'ALIASNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '值',
   'user', @CURRENTUSER, 'table', 'SYS_PAUR', 'column', 'PAURVALUE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '所属用户',
   'user', @CURRENTUSER, 'table', 'SYS_PAUR', 'column', 'USERID'
go

ALTER TABLE SYS_PAUR
   ADD CONSTRAINT PK_SYS_PAUR PRIMARY KEY NONCLUSTERED (PAURID)
go

CREATE TABLE SYS_PERSON_SCRIPT (
   ID                   NUMERIC(18,0)        NOT NULL,
   CLASS_NAME           VARCHAR(200)         NULL,
   CLASS_INS_NAME       VARCHAR(400)         NULL,
   METHOD_NAME          VARCHAR(200)         NULL,
   METHOD_DESC          VARCHAR(200)         NULL,
   RETURN_TYPE          VARCHAR(200)         NULL,
   ARGUMENT             VARCHAR(500)         NULL,
   ENABLE               NUMERIC(1,0)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户脚本管理',
   'user', @CURRENTUSER, 'table', 'SYS_PERSON_SCRIPT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_PERSON_SCRIPT', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '类名',
   'user', @CURRENTUSER, 'table', 'SYS_PERSON_SCRIPT', 'column', 'CLASS_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '类实例',
   'user', @CURRENTUSER, 'table', 'SYS_PERSON_SCRIPT', 'column', 'CLASS_INS_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '方法名称',
   'user', @CURRENTUSER, 'table', 'SYS_PERSON_SCRIPT', 'column', 'METHOD_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '方法描述',
   'user', @CURRENTUSER, 'table', 'SYS_PERSON_SCRIPT', 'column', 'METHOD_DESC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '返回类型',
   'user', @CURRENTUSER, 'table', 'SYS_PERSON_SCRIPT', 'column', 'RETURN_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '参数配置',
   'user', @CURRENTUSER, 'table', 'SYS_PERSON_SCRIPT', 'column', 'ARGUMENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '允许',
   'user', @CURRENTUSER, 'table', 'SYS_PERSON_SCRIPT', 'column', 'ENABLE'
go

ALTER TABLE SYS_PERSON_SCRIPT
   ADD CONSTRAINT PK_SYS_PERSON_SCRIPT PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_POS (
   POSID                NUMERIC(18,0)        NOT NULL,
   POSCODE 				VARCHAR(200) 		 NOT NULL,
   POSNAME              VARCHAR(100)         NOT NULL,
   POSDESC              VARCHAR(200)         NULL,
   ORGID                NUMERIC(18,0)        NULL,
   JOBID                NUMERIC(18,0)        NULL,
   ISDELETE             INT                  NULL DEFAULT 0
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '系统岗位表',
   'user', @CURRENTUSER, 'table', 'SYS_POS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '岗位ID',
   'user', @CURRENTUSER, 'table', 'SYS_POS', 'column', 'POSID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '岗位名称',
   'user', @CURRENTUSER, 'table', 'SYS_POS', 'column', 'POSNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '岗位描述',
   'user', @CURRENTUSER, 'table', 'SYS_POS', 'column', 'POSDESC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织ID',
   'user', @CURRENTUSER, 'table', 'SYS_POS', 'column', 'ORGID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '职务ID',
   'user', @CURRENTUSER, 'table', 'SYS_POS', 'column', 'JOBID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否删除',
   'user', @CURRENTUSER, 'table', 'SYS_POS', 'column', 'ISDELETE'
go

ALTER TABLE SYS_POS
   ADD CONSTRAINT PK_SYS_POS PRIMARY KEY NONCLUSTERED (POSID)
go



CREATE TABLE SYS_PROFILE (
   ID                   NUMERIC(18,0)        NOT NULL,
   USERID               NUMERIC(18,0)        NULL,
   HOMEPAGE             VARCHAR(50)          NULL,
   SKIN                 VARCHAR(20)          NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '个人个性化信息',
   'user', @CURRENTUSER, 'table', 'SYS_PROFILE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'SYS_PROFILE', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主页',
   'user', @CURRENTUSER, 'table', 'SYS_PROFILE', 'column', 'HOMEPAGE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '皮肤',
   'user', @CURRENTUSER, 'table', 'SYS_PROFILE', 'column', 'SKIN'
go

ALTER TABLE SYS_PROFILE
   ADD CONSTRAINT PK_SYS_PROFILE PRIMARY KEY NONCLUSTERED (ID)
go


CREATE TABLE SYS_REPORT (
   REPORTID             NUMERIC(18,0)        NOT NULL,
   TITLE                VARCHAR(128)         NULL,
   DESCP                VARCHAR(200)         NULL,
   FILEPATH             VARCHAR(128)         NULL,
   FILENAME             VARCHAR(128)         NULL,
   CREATETIME           DATETIME             NULL,
   STATUS               NUMERIC(1,0)         NULL DEFAULT 0,
   DSNAME               VARCHAR(50)          NULL,
   PARAMS               VARCHAR(500)         NULL DEFAULT '[]',
   TYPEID               NUMERIC(18,0)        NULL,
   EXT                  VARCHAR(20)          NULL DEFAULT 'jrxml',
   REALSQL              TEXT                 NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '报表',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '标题',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT', 'column', 'TITLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '描述',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT', 'column', 'DESCP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '报表模板文件路径',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT', 'column', 'FILEPATH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '文件名',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT', 'column', 'FILENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '状态',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT', 'column', 'STATUS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据源',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT', 'column', 'DSNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主报表参数',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT', 'column', 'PARAMS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '类型ID',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT', 'column', 'TYPEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '扩展名',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT', 'column', 'EXT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '报表模板中的SQL',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT', 'column', 'REALSQL'
go

ALTER TABLE SYS_REPORT
   ADD CONSTRAINT PK_SYS_REPORT PRIMARY KEY NONCLUSTERED (REPORTID)
go

CREATE TABLE SYS_REPORT_TEMPLATE (
   REPORTID             NUMERIC(18,0)        NOT NULL,
   TITLE                VARCHAR(128)         NOT NULL,
   DESCP                VARCHAR(500)         NOT NULL,
   REPORTLOCATION       VARCHAR(128)         NOT NULL,
   CREATETIME           DATETIME             NOT NULL,
   UPDATETIME           DATETIME             NOT NULL,
   REPORTKEY            VARCHAR(128)         NULL,
   ISDEFAULTIN          SMALLINT             NULL,
   TYPEID               NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '报表模板
   report_template',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT_TEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '报表编号',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT_TEMPLATE', 'column', 'REPORTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '标题',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT_TEMPLATE', 'column', 'TITLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '描述',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT_TEMPLATE', 'column', 'DESCP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '报表模块的jasper文件的路径',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT_TEMPLATE', 'column', 'REPORTLOCATION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT_TEMPLATE', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '修改时间',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT_TEMPLATE', 'column', 'UPDATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '标识key',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT_TEMPLATE', 'column', 'REPORTKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否缺省
   1=缺省
   0=非缺省',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT_TEMPLATE', 'column', 'ISDEFAULTIN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '报表分类ID',
   'user', @CURRENTUSER, 'table', 'SYS_REPORT_TEMPLATE', 'column', 'TYPEID'
go

ALTER TABLE SYS_REPORT_TEMPLATE
   ADD CONSTRAINT PK_SYS_REPORT_TEMPLATE PRIMARY KEY NONCLUSTERED (REPORTID)
go

CREATE TABLE SYS_RES (
   RESID                NUMERIC(18,0)        NOT NULL,
   RESNAME              VARCHAR(128)         NOT NULL,
   ALIAS                VARCHAR(128)         NULL,
   SN                   NUMERIC(18,0)        NULL,
   ICON                 VARCHAR(100)         NULL,
   PARENTID             NUMERIC(18,0)        NULL,
   DEFAULTURL           VARCHAR(256)         NULL,
   ISFOLDER             SMALLINT             NULL,
   ISDISPLAYINMENU      SMALLINT             NULL,
   ISOPEN               SMALLINT             NULL,
   SYSTEMID             NUMERIC(18,0)        NULL,
   ISNEWOPEN 			SMALLINT			 NULL,
   PATH                 VARCHAR(500)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '子系统资源',
   'user', @CURRENTUSER, 'table', 'SYS_RES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '资源主键',
   'user', @CURRENTUSER, 'table', 'SYS_RES', 'column', 'RESID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '资源名称',
   'user', @CURRENTUSER, 'table', 'SYS_RES', 'column', 'RESNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '别名（系统中唯一)',
   'user', @CURRENTUSER, 'table', 'SYS_RES', 'column', 'ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '同级排序',
   'user', @CURRENTUSER, 'table', 'SYS_RES', 'column', 'SN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '图标',
   'user', @CURRENTUSER, 'table', 'SYS_RES', 'column', 'ICON'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '父ID',
   'user', @CURRENTUSER, 'table', 'SYS_RES', 'column', 'PARENTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '默认地址',
   'user', @CURRENTUSER, 'table', 'SYS_RES', 'column', 'DEFAULTURL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '栏目',
   'user', @CURRENTUSER, 'table', 'SYS_RES', 'column', 'ISFOLDER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '显示到菜单',
   'user', @CURRENTUSER, 'table', 'SYS_RES', 'column', 'ISDISPLAYINMENU'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '默认打开',
   'user', @CURRENTUSER, 'table', 'SYS_RES', 'column', 'ISOPEN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '子系统ID',
   'user', @CURRENTUSER, 'table', 'SYS_RES', 'column', 'SYSTEMID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '资源路径',
   'user', @CURRENTUSER, 'table', 'SYS_RES', 'column', 'PATH'
go

ALTER TABLE SYS_RES
   ADD CONSTRAINT PK_SYS_RES PRIMARY KEY NONCLUSTERED (RESID)
go

CREATE TABLE SYS_RESURL (
   RESURLID             NUMERIC(18,0)        NOT NULL,
   RESID                NUMERIC(18,0)        NULL,
   NAME                 VARCHAR(100)         NULL,
   URL                  VARCHAR(200)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '资源URL',
   'user', @CURRENTUSER, 'table', 'SYS_RESURL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_RESURL', 'column', 'RESURLID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '资源ID',
   'user', @CURRENTUSER, 'table', 'SYS_RESURL', 'column', 'RESID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '名称',
   'user', @CURRENTUSER, 'table', 'SYS_RESURL', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '资源URL',
   'user', @CURRENTUSER, 'table', 'SYS_RESURL', 'column', 'URL'
go

ALTER TABLE SYS_RESURL
   ADD CONSTRAINT PK_SYS_RESURL PRIMARY KEY NONCLUSTERED (RESURLID)
go

CREATE TABLE SYS_ROLE (
   ROLEID               NUMERIC(18,0)        NOT NULL,
   SYSTEMID             NUMERIC(18,0)        NULL,
   ALIAS                VARCHAR(128)         NULL,
   ROLENAME             VARCHAR(128)         NOT NULL,
   MEMO                 VARCHAR(256)         NULL,
   ALLOWDEL             SMALLINT             NULL,
   ALLOWEDIT            SMALLINT             NULL,
   ENABLED              SMALLINT             NULL,
   CATEGORY             VARCHAR(50)          NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '系统角色表',
   'user', @CURRENTUSER, 'table', 'SYS_ROLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '系统ID',
   'user', @CURRENTUSER, 'table', 'SYS_ROLE', 'column', 'SYSTEMID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '角色别名',
   'user', @CURRENTUSER, 'table', 'SYS_ROLE', 'column', 'ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '角色名',
   'user', @CURRENTUSER, 'table', 'SYS_ROLE', 'column', 'ROLENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'SYS_ROLE', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '允许删除',
   'user', @CURRENTUSER, 'table', 'SYS_ROLE', 'column', 'ALLOWDEL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '允许编辑',
   'user', @CURRENTUSER, 'table', 'SYS_ROLE', 'column', 'ALLOWEDIT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否启用
   (0,禁止,1,启用)',
   'user', @CURRENTUSER, 'table', 'SYS_ROLE', 'column', 'ENABLED'
go

ALTER TABLE SYS_ROLE
   ADD CONSTRAINT PK_SYS_ROLE PRIMARY KEY NONCLUSTERED (ROLEID)
go


CREATE TABLE SYS_ROLE_RES (
   ROLERESID            NUMERIC(18,0)        NOT NULL,
   ROLEID               NUMERIC(18,0)        NULL,
   RESID                NUMERIC(18,0)        NULL,
   SYSTEMID             NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '角色资源映射',
   'user', @CURRENTUSER, 'table', 'SYS_ROLE_RES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '角色资源Id',
   'user', @CURRENTUSER, 'table', 'SYS_ROLE_RES', 'column', 'ROLERESID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '角色ID',
   'user', @CURRENTUSER, 'table', 'SYS_ROLE_RES', 'column', 'ROLEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '资源主键',
   'user', @CURRENTUSER, 'table', 'SYS_ROLE_RES', 'column', 'RESID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '系统ID',
   'user', @CURRENTUSER, 'table', 'SYS_ROLE_RES', 'column', 'SYSTEMID'
go

ALTER TABLE SYS_ROLE_RES
   ADD CONSTRAINT PK_SYS_ROLE_RES PRIMARY KEY NONCLUSTERED (ROLERESID)
go

CREATE TABLE SYS_SCRIPT (
   ID                   NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(50)          NULL,
   SCRIPT               TEXT                 NULL,
   CATEGORY             VARCHAR(50)          NULL,
   MEMO                 VARCHAR(200)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '系统脚本节点',
   'user', @CURRENTUSER, 'table', 'SYS_SCRIPT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_SCRIPT', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '名称',
   'user', @CURRENTUSER, 'table', 'SYS_SCRIPT', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '脚本',
   'user', @CURRENTUSER, 'table', 'SYS_SCRIPT', 'column', 'SCRIPT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '脚本分类',
   'user', @CURRENTUSER, 'table', 'SYS_SCRIPT', 'column', 'CATEGORY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'SYS_SCRIPT', 'column', 'MEMO'
go

ALTER TABLE SYS_SCRIPT
   ADD CONSTRAINT PK_SYS_SCRIPT PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_SEAL (
   SEALID               NUMERIC(18,0)        NOT NULL,
   SEALNAME             VARCHAR(128)         NULL,
   SEALPATH             VARCHAR(128)         NULL,
   BELONGID             NUMERIC(18,0)        NULL,
   BELONGNAME           VARCHAR(128)         NULL,
   ATTACHMENTID         NUMERIC(18,0)        NULL,
   SHOWIMAGEID          NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '电子印章',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL', 'column', 'SEALID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '印章名',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL', 'column', 'SEALNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '印章路径',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL', 'column', 'SEALPATH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '印章持有者ID',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL', 'column', 'BELONGID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '印章持有者姓名',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL', 'column', 'BELONGNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '印章附件',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL', 'column', 'ATTACHMENTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '印章图片',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL', 'column', 'SHOWIMAGEID'
go

ALTER TABLE SYS_SEAL
   ADD CONSTRAINT PK_SYS_SEAL PRIMARY KEY NONCLUSTERED (SEALID)
go

CREATE TABLE SYS_SEAL_RIGHT (
   ID                   NUMERIC(18,0)        NOT NULL,
   SEALID               NUMERIC(18,0)        NULL,
   RIGHTTYPE            VARCHAR(20)          NULL,
   RIGHTID              NUMERIC(18,0)        NULL,
   RIGHTNAME            VARCHAR(100)         NULL,
   CREATEUSER           VARCHAR(20)          NULL,
   CREATETIME           DATETIME             NULL,
   CONTROLTYPE          SMALLINT             NULL DEFAULT 0
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '印章授权表',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL_RIGHT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '印章ID',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL_RIGHT', 'column', 'SEALID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '授权类型',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL_RIGHT', 'column', 'RIGHTTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '被授权者ID',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL_RIGHT', 'column', 'RIGHTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '被授权者名称',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL_RIGHT', 'column', 'RIGHTNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL_RIGHT', 'column', 'CREATEUSER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL_RIGHT', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '控件类型',
   'user', @CURRENTUSER, 'table', 'SYS_SEAL_RIGHT', 'column', 'CONTROLTYPE'
go

ALTER TABLE SYS_SEAL_RIGHT
   ADD CONSTRAINT PK_SYS_SEAL_RIGHT PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_SUBSYSTEM (
   SYSTEMID             NUMERIC(18,0)        NOT NULL,
   SYSNAME              VARCHAR(50)          NOT NULL,
   ALIAS                VARCHAR(20)          NULL,
   LOGO                 VARCHAR(100)          NULL,
   DEFAULTURL           VARCHAR(50)          NULL,
   MEMO                 VARCHAR(200)         NULL,
   CREATETIME           DATETIME             NULL,
   CREATOR              VARCHAR(20)          NULL,
   ALLOWDEL             SMALLINT             NULL,
   NEEDORG              SMALLINT             NULL,
   ISACTIVE             SMALLINT             NULL,
   ISLOCAL              SMALLINT             NULL,
   HOMEPAGE             VARCHAR(256)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '子系统管理',
   'user', @CURRENTUSER, 'table', 'SYS_SUBSYSTEM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_SUBSYSTEM', 'column', 'SYSTEMID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '系统名称',
   'user', @CURRENTUSER, 'table', 'SYS_SUBSYSTEM', 'column', 'SYSNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '别名(系统中唯一)',
   'user', @CURRENTUSER, 'table', 'SYS_SUBSYSTEM', 'column', 'ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '系统的图标',
   'user', @CURRENTUSER, 'table', 'SYS_SUBSYSTEM', 'column', 'LOGO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '系统首页地址',
   'user', @CURRENTUSER, 'table', 'SYS_SUBSYSTEM', 'column', 'DEFAULTURL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'SYS_SUBSYSTEM', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'SYS_SUBSYSTEM', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'SYS_SUBSYSTEM', 'column', 'CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '允许删除',
   'user', @CURRENTUSER, 'table', 'SYS_SUBSYSTEM', 'column', 'ALLOWDEL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '选择组织架构
   (0,不需要选择,1,需要选择)
   如果用户只属于一个组织读取组织后，放到当前上下文。多个的话则需要选择。
   ',
   'user', @CURRENTUSER, 'table', 'SYS_SUBSYSTEM', 'column', 'NEEDORG'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否激活',
   'user', @CURRENTUSER, 'table', 'SYS_SUBSYSTEM', 'column', 'ISACTIVE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否本地',
   'user', @CURRENTUSER, 'table', 'SYS_SUBSYSTEM', 'column', 'ISLOCAL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '首页地址',
   'user', @CURRENTUSER, 'table', 'SYS_SUBSYSTEM', 'column', 'HOMEPAGE'
go

ALTER TABLE SYS_SUBSYSTEM
   ADD CONSTRAINT PK_SYS_SUBSYSTEM PRIMARY KEY NONCLUSTERED (SYSTEMID)
go

CREATE TABLE SYS_TEMPLATE (
   TEMPLATEID           NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(50)          NULL,
   ISDEFAULT            SMALLINT             NULL,
   USETYPE              SMALLINT             NULL,
   TITLE                VARCHAR(200)         NULL,
   PLAINCONTENT         VARCHAR(500)         NULL,
   HTMLCONTENT          VARCHAR(500)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '系统模版管理',
   'user', @CURRENTUSER, 'table', 'SYS_TEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键Id',
   'user', @CURRENTUSER, 'table', 'SYS_TEMPLATE', 'column', 'TEMPLATEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版名称',
   'user', @CURRENTUSER, 'table', 'SYS_TEMPLATE', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '系统默认',
   'user', @CURRENTUSER, 'table', 'SYS_TEMPLATE', 'column', 'ISDEFAULT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用途',
   'user', @CURRENTUSER, 'table', 'SYS_TEMPLATE', 'column', 'USETYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版标题',
   'user', @CURRENTUSER, 'table', 'SYS_TEMPLATE', 'column', 'TITLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模板普通内容',
   'user', @CURRENTUSER, 'table', 'SYS_TEMPLATE', 'column', 'PLAINCONTENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版站html内容',
   'user', @CURRENTUSER, 'table', 'SYS_TEMPLATE', 'column', 'HTMLCONTENT'
go

ALTER TABLE SYS_TEMPLATE
   ADD CONSTRAINT PK_SYS_TEMPLATE PRIMARY KEY NONCLUSTERED (TEMPLATEID)
go

CREATE TABLE SYS_TYPE_KEY (
   TYPEID               NUMERIC(18,0)        NOT NULL,
   TYPEKEY              VARCHAR(64)          NOT NULL,
   TYPENAME             VARCHAR(128)         NULL,
   FLAG                 NUMERIC(18,0)        NULL,
   SN                   NUMERIC(18,0)        NULL,
   TYPE                 NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '系统分类键',
   'user', @CURRENTUSER, 'table', 'SYS_TYPE_KEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分类Key',
   'user', @CURRENTUSER, 'table', 'SYS_TYPE_KEY', 'column', 'TYPEKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分类名',
   'user', @CURRENTUSER, 'table', 'SYS_TYPE_KEY', 'column', 'TYPENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '标识',
   'user', @CURRENTUSER, 'table', 'SYS_TYPE_KEY', 'column', 'FLAG'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '序号',
   'user', @CURRENTUSER, 'table', 'SYS_TYPE_KEY', 'column', 'SN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '0=平铺结构
   1=树型结构',
   'user', @CURRENTUSER, 'table', 'SYS_TYPE_KEY', 'column', 'TYPE'
go

ALTER TABLE SYS_TYPE_KEY
   ADD CONSTRAINT PK_SYS_TYPE_KEY PRIMARY KEY NONCLUSTERED (TYPEID)
go

CREATE TABLE SYS_URL_PERMISSION (
   ID_                  NUMERIC(18,0)        NOT NULL,
   DESCP_               VARCHAR(200)         NULL,
   URL_                 VARCHAR(2000)        NULL,
   PARAMS_              VARCHAR(500)         NULL,
   ENABLE_              SMALLINT             NULL DEFAULT 1
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'URL地址拦截管理',
   'user', @CURRENTUSER, 'table', 'SYS_URL_PERMISSION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_URL_PERMISSION', 'column', 'ID_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '描述',
   'user', @CURRENTUSER, 'table', 'SYS_URL_PERMISSION', 'column', 'DESCP_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '拦截地址',
   'user', @CURRENTUSER, 'table', 'SYS_URL_PERMISSION', 'column', 'URL_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '拦截参数',
   'user', @CURRENTUSER, 'table', 'SYS_URL_PERMISSION', 'column', 'PARAMS_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否启用0:禁用,1:启用',
   'user', @CURRENTUSER, 'table', 'SYS_URL_PERMISSION', 'column', 'ENABLE_'
go

ALTER TABLE SYS_URL_PERMISSION
   ADD CONSTRAINT PK_SYS_URL_PERMISSION PRIMARY KEY NONCLUSTERED (ID_)
go

CREATE TABLE SYS_URL_RULES (
   ID_                  NUMERIC(18,0)        NOT NULL,
   SCRIPT_              TEXT                 NULL,
   ENABLE_              SMALLINT             NULL DEFAULT 1,
   SYS_URL_ID_          NUMERIC(18,0)        NULL,
   DESCP_               VARCHAR(500)         NULL,
   SORT_                SMALLINT             NULL DEFAULT 1
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'URL地址拦截脚本管理',
   'user', @CURRENTUSER, 'table', 'SYS_URL_RULES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_URL_RULES', 'column', 'ID_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'groovy脚本',
   'user', @CURRENTUSER, 'table', 'SYS_URL_RULES', 'column', 'SCRIPT_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否启用',
   'user', @CURRENTUSER, 'table', 'SYS_URL_RULES', 'column', 'ENABLE_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'URL地址拦截管理ID',
   'user', @CURRENTUSER, 'table', 'SYS_URL_RULES', 'column', 'SYS_URL_ID_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '描述',
   'user', @CURRENTUSER, 'table', 'SYS_URL_RULES', 'column', 'DESCP_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序',
   'user', @CURRENTUSER, 'table', 'SYS_URL_RULES', 'column', 'SORT_'
go

ALTER TABLE SYS_URL_RULES
   ADD CONSTRAINT PK_SYS_URL_RULES PRIMARY KEY NONCLUSTERED (ID_)
go

CREATE TABLE SYS_USER (
   USERID               NUMERIC(18,0)        NOT NULL,
   FULLNAME             VARCHAR(127)         NULL,
   ACCOUNT              VARCHAR(20)          NOT NULL,
   PASSWORD             VARCHAR(50)          NOT NULL,
   ISEXPIRED            SMALLINT             NULL,
   ISLOCK               SMALLINT             NULL,
   CREATETIME           DATETIME             NULL,
   STATUS               SMALLINT             NULL,
   EMAIL                VARCHAR(128)         NULL,
   MOBILE               VARCHAR(32)          NULL,
   PHONE                VARCHAR(32)          NULL,
   SEX                  VARCHAR(2)           NULL,
   PICTURE              VARCHAR(300)         NULL,
   ENTRYDATE            DATETIME             NULL,
   USERSTATUS           VARCHAR(32)          NULL,
   FROMTYPE             SMALLINT             NULL,
   PWDUPDTIME           DATETIME             NULL,
   WEIXINID             VARCHAR(20)          NULL,
   HASSYNCTOWX          NUMERIC(2,0)    	 NULL DEFAULT 0
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '员工状态',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'USERSTATUS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户表',
   'user', @CURRENTUSER, 'table', 'SYS_USER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '姓名',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'FULLNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '帐号',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'ACCOUNT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '密码',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'PASSWORD'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否过期',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'ISEXPIRED'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否锁定',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'ISLOCK'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '状态
   1=激活
   0=禁用
   -1=删除',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'STATUS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '邮箱',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'EMAIL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '手机',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'MOBILE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '电话',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'PHONE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '1=男
   0=女',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'SEX'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '头像',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'PICTURE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据来源',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'FROMTYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '入职日期',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'ENTRYDATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '密码更新时间',
   'user', @CURRENTUSER, 'table', 'SYS_USER', 'column', 'PWDUPDTIME'
go
ALTER TABLE SYS_USER
   ADD CONSTRAINT PK_SYS_USER PRIMARY KEY NONCLUSTERED (USERID)
go

CREATE TABLE SYS_USER_PARAM (
   VALUEID              NUMERIC(18,0)        NOT NULL,
   USERID               NUMERIC(18,0)        NULL,
   PARAMID              NUMERIC(18,0)        NULL,
   PARAMVALUE           VARCHAR(200)         NULL,
   PARAMDATEVALUE       DATETIME             NULL,
   PARAMINTVALUE        NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户自定义参数',
   'user', @CURRENTUSER, 'table', 'SYS_USER_PARAM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键ID',
   'user', @CURRENTUSER, 'table', 'SYS_USER_PARAM', 'column', 'VALUEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'SYS_USER_PARAM', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '属性ID',
   'user', @CURRENTUSER, 'table', 'SYS_USER_PARAM', 'column', 'PARAMID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '属性值',
   'user', @CURRENTUSER, 'table', 'SYS_USER_PARAM', 'column', 'PARAMVALUE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '日期类型属性值',
   'user', @CURRENTUSER, 'table', 'SYS_USER_PARAM', 'column', 'PARAMDATEVALUE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数值型属性值',
   'user', @CURRENTUSER, 'table', 'SYS_USER_PARAM', 'column', 'PARAMINTVALUE'
go

ALTER TABLE SYS_USER_PARAM
   ADD CONSTRAINT PK_SYS_USER_PARAM PRIMARY KEY NONCLUSTERED (VALUEID)
go

CREATE TABLE SYS_USER_POS (
   USERPOSID            NUMERIC(18,0)        NOT NULL,
   POSID                NUMERIC(18,0)        NULL,
   USERID               NUMERIC(18,0)        NULL,
   ISPRIMARY            SMALLINT             NULL,
   ORGID                NUMERIC(18,0)        NULL,
   JOBID                NUMERIC(18,0)        NULL,
   ISCHARGE             SMALLINT             NULL,
   ISDELETE             SMALLINT             NULL DEFAULT 0
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户岗位表',
   'user', @CURRENTUSER, 'table', 'SYS_USER_POS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '岗位编号',
   'user', @CURRENTUSER, 'table', 'SYS_USER_POS', 'column', 'POSID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'SYS_USER_POS', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否主岗位',
   'user', @CURRENTUSER, 'table', 'SYS_USER_POS', 'column', 'ISPRIMARY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织ID',
   'user', @CURRENTUSER, 'table', 'SYS_USER_POS', 'column', 'ORGID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '职务ID',
   'user', @CURRENTUSER, 'table', 'SYS_USER_POS', 'column', 'JOBID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否负责人',
   'user', @CURRENTUSER, 'table', 'SYS_USER_POS', 'column', 'ISCHARGE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否删除',
   'user', @CURRENTUSER, 'table', 'SYS_USER_POS', 'column', 'ISDELETE'
go

ALTER TABLE SYS_USER_POS
   ADD CONSTRAINT PK_SYS_USER_POS PRIMARY KEY NONCLUSTERED (USERPOSID)
go

CREATE TABLE SYS_USER_ROLE (
   USERROLEID           NUMERIC(18,0)        NOT NULL,
   ROLEID               NUMERIC(18,0)        NULL,
   USERID               NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户角色映射表',
   'user', @CURRENTUSER, 'table', 'SYS_USER_ROLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户角色Id',
   'user', @CURRENTUSER, 'table', 'SYS_USER_ROLE', 'column', 'USERROLEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '角色ID',
   'user', @CURRENTUSER, 'table', 'SYS_USER_ROLE', 'column', 'ROLEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'SYS_USER_ROLE', 'column', 'USERID'
go

ALTER TABLE SYS_USER_ROLE
   ADD CONSTRAINT PK_SYS_USER_ROLE PRIMARY KEY NONCLUSTERED (USERROLEID)
go

CREATE TABLE SYS_USER_UNDER (
   ID                   NUMERIC(18,0)        NOT NULL,
   USERID               NUMERIC(18,0)        NULL,
   UNDERUSERID          NUMERIC(18,0)        NULL,
   UNDERUSERNAME        VARCHAR(50)          NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '下属管理',
   'user', @CURRENTUSER, 'table', 'SYS_USER_UNDER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_USER_UNDER', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'SYS_USER_UNDER', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '下属用户ID',
   'user', @CURRENTUSER, 'table', 'SYS_USER_UNDER', 'column', 'UNDERUSERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '下属用户名',
   'user', @CURRENTUSER, 'table', 'SYS_USER_UNDER', 'column', 'UNDERUSERNAME'
go

ALTER TABLE SYS_USER_UNDER
   ADD CONSTRAINT PK_SYS_USER_UNDER PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_VACATION (
   ID                   NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(50)          NULL,
   YEARS                SMALLINT             NULL,
   STATTIME             DATETIME             NULL,
   ENDTIME              DATETIME             NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '法定假期设置',
   'user', @CURRENTUSER, 'table', 'SYS_VACATION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_VACATION', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '假日名称',
   'user', @CURRENTUSER, 'table', 'SYS_VACATION', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '年份',
   'user', @CURRENTUSER, 'table', 'SYS_VACATION', 'column', 'YEARS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '开始时间',
   'user', @CURRENTUSER, 'table', 'SYS_VACATION', 'column', 'STATTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '结束时间',
   'user', @CURRENTUSER, 'table', 'SYS_VACATION', 'column', 'ENDTIME'
go

ALTER TABLE SYS_VACATION
   ADD CONSTRAINT PK_SYS_VACATION PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_WORKTIME (
   ID                   NUMERIC(18,0)        NOT NULL,
   SETTINGID            NUMERIC(18,0)        NULL,
   STARTTIME            VARCHAR(10)          NULL,
   ENDTIME              VARCHAR(10)          NULL,
   MEMO                 VARCHAR(200)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '班次时间',
   'user', @CURRENTUSER, 'table', 'SYS_WORKTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_WORKTIME', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '设置ID',
   'user', @CURRENTUSER, 'table', 'SYS_WORKTIME', 'column', 'SETTINGID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '开始时间',
   'user', @CURRENTUSER, 'table', 'SYS_WORKTIME', 'column', 'STARTTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '结束时间',
   'user', @CURRENTUSER, 'table', 'SYS_WORKTIME', 'column', 'ENDTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'SYS_WORKTIME', 'column', 'MEMO'
go

ALTER TABLE SYS_WORKTIME
   ADD CONSTRAINT PK_SYS_WORKTIME PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_WORKTIME_SETTING (
   ID                   NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(50)          NULL,
   MEMO                 VARCHAR(200)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '班次设置',
   'user', @CURRENTUSER, 'table', 'SYS_WORKTIME_SETTING'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_WORKTIME_SETTING', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '班次名',
   'user', @CURRENTUSER, 'table', 'SYS_WORKTIME_SETTING', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '描述',
   'user', @CURRENTUSER, 'table', 'SYS_WORKTIME_SETTING', 'column', 'MEMO'
go

ALTER TABLE SYS_WORKTIME_SETTING
   ADD CONSTRAINT PK_SYS_WORKTIME_SETTING PRIMARY KEY NONCLUSTERED (ID)
go

CREATE TABLE SYS_WS_DATA_TEMPLATE (
   ID                   NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(500)         NULL,
   SERVICEID            NUMERIC(18,0)        NULL,
   TEMPLATE             TEXT                 NULL,
   SCRIPT               TEXT                 NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'webservice数据模板展示',
   'user', @CURRENTUSER, 'table', 'SYS_WS_DATA_TEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '列表名称',
   'user', @CURRENTUSER, 'table', 'SYS_WS_DATA_TEMPLATE', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '对应serviceId',
   'user', @CURRENTUSER, 'table', 'SYS_WS_DATA_TEMPLATE', 'column', 'SERVICEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '展示数据的模版',
   'user', @CURRENTUSER, 'table', 'SYS_WS_DATA_TEMPLATE', 'column', 'TEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '解析返回的XML的脚本',
   'user', @CURRENTUSER, 'table', 'SYS_WS_DATA_TEMPLATE', 'column', 'SCRIPT'
go

ALTER TABLE SYS_WS_DATA_TEMPLATE
   ADD CONSTRAINT PK_SYS_WS_DATA_TEMPLATE PRIMARY KEY NONCLUSTERED (ID)
go
/*==============================================================*/
/* Table: SYS_ORG_AUTH                                          */
/*==============================================================*/
CREATE TABLE SYS_ORG_AUTH (
   ID                   NUMERIC(18)          NOT NULL,
   USER_ID              NUMERIC(18)          NOT NULL,
   ORG_ID               NUMERIC(18)          NOT NULL,
   DIM_ID               NUMERIC(18)          NOT NULL,
   ORG_PERMS            VARCHAR(255)         NULL,
   USER_PERMS           VARCHAR(255)         NULL,
   POS_PERMS            VARCHAR(255)         NULL,
   ORGAUTH_PERMS        VARCHAR(255)         NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织授权',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_AUTH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_AUTH', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '管理员ID',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_AUTH', 'column', 'USER_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织ID',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_AUTH', 'column', 'ORG_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '维度ID',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_AUTH', 'column', 'DIM_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '针对子用户组的添加、更新和删除',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_AUTH', 'column', 'ORG_PERMS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '针对用户与组关系的添加、更新和删除',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_AUTH', 'column', 'USER_PERMS'
go

ALTER TABLE SYS_ORG_AUTH
   ADD CONSTRAINT PK_SYS_ORG_AUTH PRIMARY KEY NONCLUSTERED (ID)
go
/*==============================================================*/
/* Table: SYS_AUTH_ROLE                                         */
/*==============================================================*/
CREATE TABLE SYS_AUTH_ROLE (
   ID                   NUMERIC(18,0)        NOT NULL,
   AUTH_ID              NUMERIC(18,0)        NULL,
   ROLE_ID              NUMERIC(18,0)        NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '授权角色',
   'user', @CURRENTUSER, 'table', 'SYS_AUTH_ROLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_AUTH_ROLE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '授权ID',
   'user', @CURRENTUSER, 'table', 'SYS_AUTH_ROLE', 'column', 'AUTH_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '角色ID',
   'user', @CURRENTUSER, 'table', 'SYS_AUTH_ROLE', 'column', 'ROLE_ID'
go

ALTER TABLE SYS_AUTH_ROLE
   ADD CONSTRAINT PK_SYS_AUTH_ROLE PRIMARY KEY NONCLUSTERED (ID)
go


CREATE TABLE SYS_DATA_SOURCE
(
  ID_            NUMERIC(18) NOT NULL,
  NAME_          VARCHAR(64),
  ALIAS_         VARCHAR(64),
  DB_TYPE_       VARCHAR(64),
  SETTING_JSON_  TEXT,
  INIT_ON_START_ NUMERIC,
  ENABLED_       NUMERIC,
  CLASS_PATH_    VARCHAR(128),
  INIT_METHOD_   VARCHAR(128),
  CLOSE_METHOD_  VARCHAR(128)
);

alter table SYS_DATA_SOURCE
  add constraint ID_PRIMAR primary key (ID_);
alter table SYS_DATA_SOURCE
  add constraint UNIQUE_COLUMN unique (NAME_, ALIAS_);

CREATE TABLE SYS_DATA_SOURCE_DEF
(
  ID_           NUMERIC(18) NOT NULL,
  NAME_         VARCHAR(64) NOT NULL,
  CLASS_PATH_   VARCHAR(128) NOT NULL,
  SETTING_JSON_ TEXT,
  INIT_METHOD_  VARCHAR(64),
  IS_SYSTEM_    NUMERIC,
  CLOSE_METHOD_ VARCHAR(64)
);

ALTER TABLE SYS_DATA_SOURCE_DEF
  ADD CONSTRAINT ID_PRIMARY PRIMARY KEY (ID_);
ALTER TABLE SYS_DATA_SOURCE_DEF
  ADD CONSTRAINT UNIQUE_COLUMNS UNIQUE (NAME_, CLASS_PATH_);

  
 CREATE TABLE BPM_DEF_AUTH_TYPE  (
   ID  NUMERIC(18,0) NOT NULL ,
   AUTHORIZE_ID  NUMERIC(18,0) NOT NULL ,
   AUTHORIZE_TYPE   VARCHAR(64) ,
   PRIMARY KEY (ID)
)
go

EXECUTE SYS.SP_ADDEXTENDEDPROPERTY @NAME=N'MS_Description', @VALUE=N'流程授权类型表' ,@LEVEL0TYPE=N'SCHEMA', @LEVEL0NAME=N'dbo', @LEVEL1TYPE=N'TABLE', @LEVEL1NAME=N'BPM_DEF_AUTH_TYPE'
go

EXECUTE SYS.SP_ADDEXTENDEDPROPERTY @NAME=N'MS_Description', @VALUE=N'主键' ,@LEVEL0TYPE=N'SCHEMA', @LEVEL0NAME=N'dbo', @LEVEL1TYPE=N'TABLE', @LEVEL1NAME=N'BPM_DEF_AUTH_TYPE', @LEVEL2TYPE=N'COLUMN', @LEVEL2NAME=N'ID'
go

EXECUTE SYS.SP_ADDEXTENDEDPROPERTY @NAME=N'MS_Description', @VALUE=N'流程授权主表ID' ,@LEVEL0TYPE=N'SCHEMA', @LEVEL0NAME=N'dbo', @LEVEL1TYPE=N'TABLE', @LEVEL1NAME=N'BPM_DEF_AUTH_TYPE', @LEVEL2TYPE=N'COLUMN', @LEVEL2NAME=N'AUTHORIZE_ID'
go

EXECUTE SYS.SP_ADDEXTENDEDPROPERTY @NAME=N'MS_Description', @VALUE=N'流程授权类型' ,@LEVEL0TYPE=N'SCHEMA', @LEVEL0NAME=N'dbo', @LEVEL1TYPE=N'TABLE', @LEVEL1NAME=N'BPM_DEF_AUTH_TYPE', @LEVEL2TYPE=N'COLUMN', @LEVEL2NAME=N'AUTHORIZE_TYPE'
go
 
/*==============================================================*/
/* Table: BPM_FORM_DEF_HI                                       */
/*==============================================================*/
CREATE TABLE BPM_FORM_DEF_HI (
   HISID                NUMERIC(18,0)        NOT NULL,
   FORMDEFID            NUMERIC(18,0)        NOT NULL,
   CATEGORYID           NUMERIC(18,0)        NULL,
   FORMKEY              VARCHAR(128)         NULL,
   SUBJECT              VARCHAR(128)         NULL,
   FORMDESC             VARCHAR(200)         NULL,
   HTML                 TEXT                 NULL,
   TEMPLATE             TEXT                 NULL,
   ISDEFAULT            SMALLINT             NULL,
   VERSIONNO            NUMERIC(18,0)        NULL,
   TABLEID              NUMERIC(18,0)        NULL,
   ISPUBLISHED          SMALLINT             NULL,
   PUBLISHEDBY          VARCHAR(20)          NULL,
   PUBLISHTIME          DATETIME             NULL,
   TABTITLE             VARCHAR(500)         NULL,
   DESIGNTYPE           SMALLINT             NULL,
   TEMPLATESID          VARCHAR(300)         NULL,
   CREATEBY             NUMERIC(18,0)        NULL,
   CREATOR              VARCHAR(50)          NULL,
   CREATETIME           DATETIME             NULL
)
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'HISID')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'HISID'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '主键',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'HISID'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'FORMDEFID')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'FORMDEFID'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '表单ID',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'FORMDEFID'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'CATEGORYID')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'CATEGORYID'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '表单分类',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'CATEGORYID'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'FORMKEY')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'FORMKEY'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '表单KEY',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'FORMKEY'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'SUBJECT')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'SUBJECT'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '表单标题',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'SUBJECT'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'FORMDESC')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'FORMDESC'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '描述',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'FORMDESC'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'HTML')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'HTML'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '定义HTML',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'HTML'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'TEMPLATE')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'TEMPLATE'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'FREEMAKER模版',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'TEMPLATE'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'ISDEFAULT')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'ISDEFAULT'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '是否缺省',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'ISDEFAULT'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'VERSIONNO')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'VERSIONNO'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '版本号',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'VERSIONNO'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'TABLEID')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'TABLEID'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '表ID',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'TABLEID'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'ISPUBLISHED')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'ISPUBLISHED'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '是否发布',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'ISPUBLISHED'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'PUBLISHEDBY')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'PUBLISHEDBY'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '发布人',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'PUBLISHEDBY'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'PUBLISHTIME')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'PUBLISHTIME'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '发布时间',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'PUBLISHTIME'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'TABTITLE')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'TABTITLE'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'TAB标题',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'TABTITLE'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'DESIGNTYPE')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'DESIGNTYPE'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '设计类型',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'DESIGNTYPE'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'TEMPLATESID')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'TEMPLATESID'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '模板表对应ID',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'TEMPLATESID'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'CREATEBY')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'CREATEBY'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '创建人ID',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'CREATEBY'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'CREATOR')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'CREATOR'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '创建人',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'CREATOR'
GO

IF EXISTS(SELECT 1 FROM SYS.EXTENDED_PROPERTIES P WHERE
      P.MAJOR_ID = OBJECT_ID('BPM_FORM_DEF_HI')
  AND P.MINOR_ID = (SELECT C.COLUMN_ID FROM SYS.COLUMNS C WHERE C.OBJECT_ID = P.MAJOR_ID AND C.NAME = 'CREATETIME')
)
BEGIN
   DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_DROPEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'CREATETIME'

END


SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_DESCRIPTION', 
   '创建时间',
   'USER', @CURRENTUSER, 'TABLE', 'BPM_FORM_DEF_HI', 'COLUMN', 'CREATETIME'
GO

ALTER TABLE BPM_FORM_DEF_HI
   ADD CONSTRAINT PK_BPM_FORM_DEF_HI PRIMARY KEY NONCLUSTERED (HISID)
GO

CREATE TABLE BPM_ASSIGN_USERS (
   ID                   NUMERIC(18,0)                  NOT NULL,
   RUNID                NUMERIC(18,0)                 NULL,
   DEFKEY               VARCHAR(128)         NULL,
   NODEID               VARCHAR(128)         NULL,
   NODENAME             VARCHAR(256)         NULL,
   USERID               VARCHAR(20)          NULL,
   USERNAME             VARCHAR(127)         NULL,
   STARTTIME            DATETIME             NULL,
   ENDTIME              DATETIME             NULL,
   CONSTRAINT PK_BPM_ASSIGN_USERS PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_ASSIGN_USERS', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程执行实例ID',
   'user', @CURRENTUSER, 'table', 'BPM_ASSIGN_USERS', 'column', 'RUNID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义Key',
   'user', @CURRENTUSER, 'table', 'BPM_ASSIGN_USERS', 'column', 'DEFKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_ASSIGN_USERS', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点名称',
   'user', @CURRENTUSER, 'table', 'BPM_ASSIGN_USERS', 'column', 'NODENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '执行人ID',
   'user', @CURRENTUSER, 'table', 'BPM_ASSIGN_USERS', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '执行人名称',
   'user', @CURRENTUSER, 'table', 'BPM_ASSIGN_USERS', 'column', 'USERNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '开始时间',
   'user', @CURRENTUSER, 'table', 'BPM_ASSIGN_USERS', 'column', 'STARTTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '结束时间',
   'user', @CURRENTUSER, 'table', 'BPM_ASSIGN_USERS', 'column', 'ENDTIME'
go


/*==============================================================*/
/* Table: BPM_NODE_SQL                                          */
/*==============================================================*/
CREATE TABLE BPM_NODE_SQL (
   ID                   NUMERIC(18)          NOT NULL DEFAULT 0,
   NAME                 VARCHAR(100)         NULL,
   DSALIAS              VARCHAR(100)         NULL,
   ACTDEFID             VARCHAR(100)         NULL,
   NODEID               VARCHAR(50)          NULL,
   ACTION_              VARCHAR(50)          NULL,
   SQL_                 VARCHAR(4000)        NULL,
   DESC_                VARCHAR(400)         NULL,
   CONSTRAINT PK_BPM_NODE_SQL PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SQL', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据源别名',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SQL', 'column', 'DSALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程id',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SQL', 'column', 'ACTDEFID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SQL', 'column', 'NODEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '触发时机：\r\nSubmit\r\nAgree\r\nOpposite\r\nReject\r\ndelete\r\nsave\r\nend\r\n',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SQL', 'column', 'ACTION_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'SQL语句',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SQL', 'column', 'SQL_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '描叙',
   'user', @CURRENTUSER, 'table', 'BPM_NODE_SQL', 'column', 'DESC_'
go

/*==============================================================*/
/* Table: BPM_SUBTABLE_SORT                                     */
/*==============================================================*/
CREATE TABLE BPM_SUBTABLE_SORT (
   ID                   NUMERIC(20,0)        NOT NULL,
   ACTDEFKEY            VARCHAR(120)         NULL,
   TABLENAME            VARCHAR(120)         NULL,
   FIELDSORT            VARCHAR(500)         NULL,
   CONSTRAINT PK_BPM_SUBTABLE_SORT PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_SUBTABLE_SORT', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义key',
   'user', @CURRENTUSER, 'table', 'BPM_SUBTABLE_SORT', 'column', 'ACTDEFKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '子表名称',
   'user', @CURRENTUSER, 'table', 'BPM_SUBTABLE_SORT', 'column', 'TABLENAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '字段名，json数据',
   'user', @CURRENTUSER, 'table', 'BPM_SUBTABLE_SORT', 'column', 'FIELDSORT'
go


/*==============================================================*/
/* Table: SYS_INDEX_LAYOUT                                      */
/*==============================================================*/
CREATE TABLE SYS_INDEX_LAYOUT (
   ID                   NUMERIC(18)          NOT NULL,
   NAME                 VARCHAR(100)         NULL,
   MEMO                 VARCHAR(256)         NULL,
   TEMPLATE_HTML        TEXT                 NULL,
   SN                   NUMERIC(18)          NULL,
   CONSTRAINT PK_SYS_INDEX_LAYOUT PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '布局名称',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '布局描述',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版内容',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT', 'column', 'TEMPLATE_HTML'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT', 'column', 'SN'
go

/*==============================================================*/
/* Table: SYS_INDEX_LAYOUT_MANAGE                               */
/*==============================================================*/
CREATE TABLE SYS_INDEX_LAYOUT_MANAGE (
   ID                   NUMERIC(18)          NOT NULL,
   NAME                 VARCHAR(100)         NULL,
   MEMO                 VARCHAR(256)         NULL,
   ORG_ID               NUMERIC(18)          NULL,
   TEMPLATE_HTML        TEXT                 NULL,
   DESIGN_HTML          TEXT                 NULL,
   IS_DEF               NUMERIC(18)          NULL,
   CONSTRAINT PK_SYS_INDEX_LAYOUT_MANAGE PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT_MANAGE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '布局名称',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT_MANAGE', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '布局描述',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT_MANAGE', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织ID',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT_MANAGE', 'column', 'ORG_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版内容',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT_MANAGE', 'column', 'TEMPLATE_HTML'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '设计模版',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT_MANAGE', 'column', 'DESIGN_HTML'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否是默认',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT_MANAGE', 'column', 'IS_DEF'
go


/*==============================================================*/
/* Table: SYS_INDEX_LAYOUT_RIGHTS                               */
/*==============================================================*/
CREATE TABLE SYS_INDEX_LAYOUT_RIGHTS (
   ID                   NUMERIC(18)          NOT NULL,
   MANAGE_ID            NUMERIC(18)          NULL,
   OWNER_ID             NUMERIC(18)          NULL,
   OWNER_NAME           VARCHAR(256)         NULL,
   RIGHT_TYPE           VARCHAR(20)          NULL,
   CONSTRAINT PK_SYS_INDEX_LAYOUT_RIGHTS PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT_RIGHTS', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '布局ID',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT_RIGHTS', 'column', 'MANAGE_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '授权对象ID',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT_RIGHTS', 'column', 'OWNER_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '授权对象名称',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT_RIGHTS', 'column', 'OWNER_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '授权对象类型',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_LAYOUT_RIGHTS', 'column', 'RIGHT_TYPE'
go

/*==============================================================*/
/* Table: SYS_INDEX_MY_LAYOUT                                   */
/*==============================================================*/
CREATE TABLE SYS_INDEX_MY_LAYOUT (
   ID                   NUMERIC(18)          NOT NULL,
   USER_ID              NUMERIC(18)          NULL,
   TEMPLATE_HTML        TEXT                 NULL,
   DESIGN_HTML          TEXT                 NULL,
   LAYOUT_ID            NUMERIC(18)          NULL,
   CONSTRAINT PK_SYS_INDEX_MY_LAYOUT PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_MY_LAYOUT', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_MY_LAYOUT', 'column', 'USER_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版内容',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_MY_LAYOUT', 'column', 'TEMPLATE_HTML'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '设计模版',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_MY_LAYOUT', 'column', 'DESIGN_HTML'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '布局管理ID',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_MY_LAYOUT', 'column', 'LAYOUT_ID'
go


/*==============================================================*/
/* Table: SYS_ORG_TACTIC                                        */
/*==============================================================*/
CREATE TABLE SYS_ORG_TACTIC (
   ID                   NUMERIC(18)          NOT NULL,
   ORG_TACTIC           NUMERIC(18)          NULL,
   DEM_ID               NUMERIC(18)          NULL,
   ORG_TYPE            NUMERIC(18)          NULL,
   ORG_SELECT_ID        NUMERIC(18)          NULL,
   CONSTRAINT PK_SYS_ORG_TACTIC PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_TACTIC', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '策略（0、无策略1、按照级别 2、手工选择，3、按照级别+手工选择）',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_TACTIC', 'column', 'ORG_TACTIC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '维度ID',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_TACTIC', 'column', 'DEM_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织级别',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_TACTIC', 'column', 'ORG_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织选择ID',
   'user', @CURRENTUSER, 'table', 'SYS_ORG_TACTIC', 'column', 'ORG_SELECT_ID'
go

/*==============================================================*/
/* Table: SYS_WORD_TEMPLATE                                     */
/*==============================================================*/
CREATE TABLE SYS_WORD_TEMPLATE (
   ID_                  NUMERIC(18)          NOT NULL,
   NAME_                VARCHAR(200)         NULL,
   ALIAS_               VARCHAR(200)         NULL,
   FILE_ID_             NUMERIC(18)          NULL,
   CREATETIME_          NUMERIC(18)          NULL,
   TYPE_                VARCHAR(20)          NULL,
   TABLE_ID_            NUMERIC(18)          NULL,
   TABLE_NAME_          VARCHAR(128)         NULL,
   DS_ALIAS_            VARCHAR(50)          NULL,
   SQL_                 TEXT                 NULL,
   CONSTRAINT PK_SYS_WORD_TEMPLATE PRIMARY KEY NONCLUSTERED (ID_)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_WORD_TEMPLATE', 'column', 'ID_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '报表名称',
   'user', @CURRENTUSER, 'table', 'SYS_WORD_TEMPLATE', 'column', 'NAME_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '报表别名',
   'user', @CURRENTUSER, 'table', 'SYS_WORD_TEMPLATE', 'column', 'ALIAS_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'word模板附件ID',
   'user', @CURRENTUSER, 'table', 'SYS_WORD_TEMPLATE', 'column', 'FILE_ID_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'SYS_WORD_TEMPLATE', 'column', 'CREATETIME_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '类型\r\nSQL\r\n自定义表单\r\n1.如果类型为sql则根据数据源，sql语句获取数据。\r\n2.为表单则根据表定义和主键获取数据。',
   'user', @CURRENTUSER, 'table', 'SYS_WORD_TEMPLATE', 'column', 'TYPE_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表ID',
   'user', @CURRENTUSER, 'table', 'SYS_WORD_TEMPLATE', 'column', 'TABLE_ID_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表名',
   'user', @CURRENTUSER, 'table', 'SYS_WORD_TEMPLATE', 'column', 'TABLE_NAME_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据源别名',
   'user', @CURRENTUSER, 'table', 'SYS_WORD_TEMPLATE', 'column', 'DS_ALIAS_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'Sql语句',
   'user', @CURRENTUSER, 'table', 'SYS_WORD_TEMPLATE', 'column', 'SQL_'
go


/*==============================================================*/
/* Table: SYS_INDEX_COLUMN                                      */
/*==============================================================*/
CREATE TABLE SYS_INDEX_COLUMN (
   ID                   BIGINT               NOT NULL,
   NAME                 VARCHAR(100)         NULL,
   ALIAS                VARCHAR(100)         NULL,
   CATALOG              BIGINT               NULL,
   COL_TYPE             SMALLINT             NULL,
   DATA_MODE            SMALLINT             NULL,
   DATA_FROM            VARCHAR(100)         NULL,
   DS_ALIAS             VARCHAR(100)         NULL,
   DS_NAME              VARCHAR(100)         NULL,
   COL_HEIGHT           INT                  NULL,
   COL_URL              VARCHAR(100)         NULL,
   TEMPLATE_HTML        TEXT                 NULL,
   IS_PUBLIC            SMALLINT             NULL,
   ORG_ID               BIGINT               NULL,
   SUPPORT_REFESH       SMALLINT             NULL,
   REFESH_TIME          INT                  NULL,
   SHOW_EFFECT          SMALLINT             NULL,
   MEMO                 VARCHAR(256)         NULL,
   DATA_PARAM           VARCHAR(2000)        NULL,
   NEEDPAGE             SMALLINT,
   CONSTRAINT PK_SYS_INDEX_COLUMN PRIMARY KEY (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '栏目名称',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '栏目别名',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '栏目分类',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'CATALOG'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '栏目类型（0：一般栏目、1：图表栏目、2、滚动栏目）',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'COL_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据加载方式(0:服务方法;1:自定义查询)',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'DATA_MODE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据来源',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'DATA_FROM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据别名',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'DS_ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据源名称',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'DS_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '栏目高度',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'COL_HEIGHT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '栏目URL',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'COL_URL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '栏目模版',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'TEMPLATE_HTML'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否公共栏目',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'IS_PUBLIC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '所属组织ID',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'ORG_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否支持刷新',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'SUPPORT_REFESH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '刷新时间',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'REFESH_TIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '展示效果',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'SHOW_EFFECT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '描述',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN', 'column', 'MEMO'
go


/*==============================================================*/
/* Table: SYS_INDEX_COLUMN_RIGHTS                               */
/*==============================================================*/
CREATE TABLE SYS_INDEX_COLUMN_RIGHTS (
   ID                   NUMERIC(18,0)        NOT NULL,
   COLUMN_ID            NUMERIC(18,0)        NULL,
   OWNER_ID             NUMERIC(18,0)        NULL,
   OWNER_NAME           VARCHAR(256)         NULL,
   RIGHT_TYPE           VARCHAR(20)          NULL,
   CONSTRAINT PK_SYS_INDEX_COLUMN_RIGHTS PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN_RIGHTS', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '栏目ID',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN_RIGHTS', 'column', 'COLUMN_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '授权对象ID',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN_RIGHTS', 'column', 'OWNER_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '授权对象名称',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN_RIGHTS', 'column', 'OWNER_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '授权对象类型',
   'user', @CURRENTUSER, 'table', 'SYS_INDEX_COLUMN_RIGHTS', 'column', 'RIGHT_TYPE'
go

/*==============================================================*/
/* Table: SYS_POPUP_REMIND                                      */
/*==============================================================*/
CREATE TABLE SYS_POPUP_REMIND (
   ID                   NUMERIC(18,0)                  NOT NULL,
   SUBJECT              VARCHAR(200)         NULL,
   URL                  VARCHAR(200)         NULL,
   SQL_                 VARCHAR(2000)        NULL,
   DSALIAS              VARCHAR(20)          NULL,
   SN                   NUMERIC(18,0)        NULL,
   ENABLED              NUMERIC(18,0)        NULL,
   CREATETIME           DATE                 NULL,
   CREATOR              VARCHAR(50)          NULL,
   DESC_                VARCHAR(300)         NULL,
   POPUP_TYPE           VARCHAR(200)         NULL,
   RESERVE              VARCHAR(1000)         NULL,
   CONSTRAINT PK_SYS_POPUP_REMIND PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_POPUP_REMIND', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主题 弹框时的信息',
   'user', @CURRENTUSER, 'table', 'SYS_POPUP_REMIND', 'column', 'SUBJECT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '点击该提醒的跳转URL',
   'user', @CURRENTUSER, 'table', 'SYS_POPUP_REMIND', 'column', 'URL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'SQL 返回数据大小',
   'user', @CURRENTUSER, 'table', 'SYS_POPUP_REMIND', 'column', 'SQL_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据源别名',
   'user', @CURRENTUSER, 'table', 'SYS_POPUP_REMIND', 'column', 'DSALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序',
   'user', @CURRENTUSER, 'table', 'SYS_POPUP_REMIND', 'column', 'SN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否启用',
   'user', @CURRENTUSER, 'table', 'SYS_POPUP_REMIND', 'column', 'ENABLED'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'SYS_POPUP_REMIND', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人 json.id,json.name',
   'user', @CURRENTUSER, 'table', 'SYS_POPUP_REMIND', 'column', 'CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '描述',
   'user', @CURRENTUSER, 'table', 'SYS_POPUP_REMIND', 'column', 'DESC_'
go


/*==============================================================*/
/* Table: SYS_OBJ_RIGHTS                                        */
/*==============================================================*/
CREATE TABLE SYS_OBJ_RIGHTS (
   ID                   NUMERIC(18,0)       NOT NULL,
   OBJ_TYPE             VARCHAR(20)          NULL,
   OBJECT_ID            BIGINT               NULL,
   OWNER_ID             BIGINT               NULL,
   OWNER                VARCHAR(50)          NULL,
   RIGHT_TYPE           VARCHAR(10)          NULL,
   CONSTRAINT PK_SYS_OBJ_RIGHTS PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_OBJ_RIGHTS', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '对象类型',
   'user', @CURRENTUSER, 'table', 'SYS_OBJ_RIGHTS', 'column', 'OBJ_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '权限对象ID',
   'user', @CURRENTUSER, 'table', 'SYS_OBJ_RIGHTS', 'column', 'OBJECT_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '授权人ID',
   'user', @CURRENTUSER, 'table', 'SYS_OBJ_RIGHTS', 'column', 'OWNER_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '授权人',
   'user', @CURRENTUSER, 'table', 'SYS_OBJ_RIGHTS', 'column', 'OWNER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '权限类型',
   'user', @CURRENTUSER, 'table', 'SYS_OBJ_RIGHTS', 'column', 'RIGHT_TYPE'
go

/*==============================================================*/
/* Table: SYS_PROPERTY                                          */
/*==============================================================*/
CREATE TABLE SYS_PROPERTY (
   ID                   NUMERIC(18,0)        NOT NULL,
   NAME_                VARCHAR(128)         NULL,
   ALIAS_               VARCHAR(128)         NULL,
   VALUE_               VARCHAR(256)         NULL,
   GROUP_               VARCHAR(128)         NULL,
   SN_                  SMALLINT             NULL,
   MEMO                 VARCHAR(200)         NULL,
   CONSTRAINT PK_SYS_PROPERTY PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_PROPERTY', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '名字',
   'user', @CURRENTUSER, 'table', 'SYS_PROPERTY', 'column', 'NAME_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '别名',
   'user', @CURRENTUSER, 'table', 'SYS_PROPERTY', 'column', 'ALIAS_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '值',
   'user', @CURRENTUSER, 'table', 'SYS_PROPERTY', 'column', 'VALUE_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '参数描述',
   'user', @CURRENTUSER, 'table', 'SYS_PROPERTY', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分组',
   'user', @CURRENTUSER, 'table', 'SYS_PROPERTY', 'column', 'GROUP_'
go

/*==============================================================*/
/* Table: BPM_BATCH_APPROVAL                                    */
/*==============================================================*/
CREATE TABLE BPM_BATCH_APPROVAL (
   ID                   NUMERIC(18)          NOT NULL,
   DEF_KEY              VARCHAR(128)         NULL,
   NODE_ID              VARCHAR(128)         NULL,
   TABLE_ID             NUMERIC(18)          NULL,
   FIELD_JSON           TEXT                 NULL,
   CONSTRAINT PK_BPM_BATCH_APPROVAL PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'BPM_BATCH_APPROVAL', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '流程定义Key',
   'user', @CURRENTUSER, 'table', 'BPM_BATCH_APPROVAL', 'column', 'DEF_KEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点ID',
   'user', @CURRENTUSER, 'table', 'BPM_BATCH_APPROVAL', 'column', 'NODE_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '自定义表ID',
   'user', @CURRENTUSER, 'table', 'BPM_BATCH_APPROVAL', 'column', 'TABLE_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '字段设置',
   'user', @CURRENTUSER, 'table', 'BPM_BATCH_APPROVAL', 'column', 'FIELD_JSON'
go


/*==============================================================*/
/* Table: SYS_BULLETIN_COLUMN                                   */
/*==============================================================*/
CREATE TABLE SYS_BULLETIN_COLUMN (
   ID                   NUMERIC(18)          NOT NULL,
   NAME                 VARCHAR(100)         NULL,
   ALIAS                VARCHAR(20)          NULL,
   ISPUBLIC             SMALLINT             NULL,
   TENANTID             NUMERIC(18)          NULL,
   CREATORID            NUMERIC(18)          NULL,
   CREATOR              VARCHAR(50)          NULL,
   CREATETIME           DATETIME             NULL,
   STATUS               SMALLINT             NULL,
   IMGURL               VARCHAR(50)          NULL,
   CONSTRAINT PK_SYS_BULLETIN_COLUMN PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN_COLUMN', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '栏目名',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN_COLUMN', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '别名',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN_COLUMN', 'column', 'ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否是集团栏目',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN_COLUMN', 'column', 'ISPUBLIC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织id',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN_COLUMN', 'column', 'TENANTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人id',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN_COLUMN', 'column', 'CREATORID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN_COLUMN', 'column', 'CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN_COLUMN', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '状态',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN_COLUMN', 'column', 'STATUS'
go


/*==============================================================*/
/* Table: SYS_BULLETIN                                          */
/*==============================================================*/
CREATE TABLE SYS_BULLETIN (
   ID                   NUMERIC(18)          NOT NULL,
   SUBJECT              VARCHAR(200)         NULL,
   COLUMNID             NUMERIC(18)          NULL,
   CONTENT              TEXT                 NULL,
   CREATORID            NUMERIC(18)          NULL,
   CREATOR              VARCHAR(50)          NULL,
   CREATETIME           DATETIME             NULL,
   ATTACHMENT           VARCHAR(400)         NULL,
   STATUS               SMALLINT             NULL,
   IMGURL               VARCHAR(50)          NULL,
   CONSTRAINT PK_SYS_BULLETIN PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主题',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN', 'column', 'SUBJECT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '栏目id',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN', 'column', 'COLUMNID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '内容',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN', 'column', 'CONTENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人id',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN', 'column', 'CREATORID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN', 'column', 'CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '附件',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN', 'column', 'ATTACHMENT'
go


/*==============================================================*/
/* Table: SYS_PLAN_EXCHANGE                                     */
/*==============================================================*/
CREATE TABLE SYS_PLAN_EXCHANGE (
   ID                   BIGINT               NOT NULL,
   PLANID               BIGINT               NULL,
   SUBMITID             BIGINT               NULL,
   SUBMITOR             VARCHAR(50)          NULL,
   DOC                  VARCHAR(400)         NULL,
   CONTENT              VARCHAR(1000)        NULL,
   CREATETIME           TIMESTAMP            NULL,
   CONSTRAINT PK_SYS_PLAN_EXCHANGE PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_EXCHANGE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '日程ID',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_EXCHANGE', 'column', 'PLANID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '提交人ID',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_EXCHANGE', 'column', 'SUBMITID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '提交人',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_EXCHANGE', 'column', 'SUBMITOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '相关文档',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_EXCHANGE', 'column', 'DOC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '交流内容',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_EXCHANGE', 'column', 'CONTENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '提交时间',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_EXCHANGE', 'column', 'CREATETIME'
go
/*==============================================================*/
/* Table: SYS_PLAN_PARTICIPANTS                                 */
/*==============================================================*/
CREATE TABLE SYS_PLAN_PARTICIPANTS (
   ID                   BIGINT               NOT NULL,
   PLANID               BIGINT               NULL,
   PARTICIPANTID        BIGINT               NULL,
   PARTICIPANT          VARCHAR(50)          NULL,
   CONSTRAINT PK_SYS_PLAN_PARTICIPANTS PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_PARTICIPANTS', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '日程ID',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_PARTICIPANTS', 'column', 'PLANID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '参与者ID',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_PARTICIPANTS', 'column', 'PARTICIPANTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '参与者',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_PARTICIPANTS', 'column', 'PARTICIPANT'
go
/*==============================================================*/
/* Table: SYS_PLAN_SUBSCRIBE                                    */
/*==============================================================*/
CREATE TABLE SYS_PLAN_SUBSCRIBE (
   ID                   BIGINT               NOT NULL,
   PLANID               BIGINT               NULL,
   SUBSCRIBEID          BIGINT               NULL,
   SUBSCRIBE            VARCHAR(50)          NULL,
   SUBSCRIBETIME        TIMESTAMP            NULL,
   CONSTRAINT PK_SYS_PLAN_SUBSCRIBE PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_SUBSCRIBE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '日程ID',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_SUBSCRIBE', 'column', 'PLANID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '订阅者ID',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_SUBSCRIBE', 'column', 'SUBSCRIBEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '订阅者',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_SUBSCRIBE', 'column', 'SUBSCRIBE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '订阅时间',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN_SUBSCRIBE', 'column', 'SUBSCRIBETIME'
go
/*==============================================================*/
/* Table: SYS_PLAN                                              */
/*==============================================================*/
CREATE TABLE SYS_PLAN (
   ID                   BIGINT               NOT NULL,
   TASKNAME             VARCHAR(200)         NULL,
   SUBMITID             BIGINT               NULL,
   SUBMITOR             VARCHAR(50)          NULL,
   CHARGEID             BIGINT               NULL,
   CHARGE               VARCHAR(50)          NULL,
   STARTTIME            DATETIME            NULL,
   ENDTIME              DATETIME            NULL,
   PROJECTNAME          VARCHAR(200)         NULL,
   DOC                  VARCHAR(400)         NULL,
   CUSTOMERID           BIGINT               NULL,
   CUSTOMER             VARCHAR(200)         NULL,
   RUNID                BIGINT               NULL,
   RUNNAME              VARCHAR(200)         NULL,
   RATE                 BIGINT               NULL,
   CREATETIME           TIMESTAMP            NULL,
   DESCRIPTION          VARCHAR(2000)        NULL,
   CONSTRAINT PK_SYS_PLAN PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务名称',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'TASKNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '提交人ID',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'SUBMITID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '提交人',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'SUBMITOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '负责人ID',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'CHARGEID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '负责人',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'CHARGE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '开始时间',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'STARTTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '结束时间',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'ENDTIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '项目名称',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'PROJECTNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '相关文档',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'DOC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '相关客户ID',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'CUSTOMERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '相关客户',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'CUSTOMER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '相关工单ID',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'RUNID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '工单名称',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'RUNNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '完成进度',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'RATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '任务内容',
   'user', @CURRENTUSER, 'table', 'SYS_PLAN', 'column', 'DESCRIPTION'
go


/*==============================================================*/
/* Table: SYS_OBJ_LOG                                           */
/*==============================================================*/
CREATE TABLE SYS_OBJ_LOG (
   ID                   NUMERIC(18,0)        NOT NULL,
   OPERATOR_ID          NUMERIC(18,0)        NULL,
   OPERATOR             VARCHAR(255)         NULL,
   CREATE_TIME          DATETIME             NULL,
   NAME                 VARCHAR(255)         NULL,
   CONTENT              TEXT                 NULL,
   OBJ_TYPE             VARCHAR(255)         NULL,
   PARAM                VARCHAR(255)         NULL,
   CONSTRAINT PK_SYS_OBJ_LOG PRIMARY KEY NONCLUSTERED (ID)
)
go

/*==============================================================*/
/* Table: SYS_TRANS_DEF                                         */
/*==============================================================*/
CREATE TABLE SYS_TRANS_DEF (
   ID                   NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(100)         NULL,
   SELECTSQL            TEXT                 NULL,
   UPDATESQL            TEXT                 NULL,
   STATE                SMALLINT             NULL,
   CREATORID            NUMERIC(18,0)        NULL,
   CREATOR              VARCHAR(50)          NULL,
   CREATETIME           DATETIME             NULL,
   LOGCONTENT           VARCHAR(500)         NULL,
   CONSTRAINT PK_SYS_TRANS_DEF PRIMARY KEY NONCLUSTERED (ID)
)
go

CREATE TABLE BPM_FORM_DIALOG_COMBINATE (
   ID                   NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(200)         NULL,
   ALIAS                VARCHAR(200)         NULL,
   WIDTH                INT                  NULL,
   HEIGHT               INT                  NULL,
   TREE_DIALOG_ID       NUMERIC(18,0)        NULL,
   TREE_DIALOG_NAME     VARCHAR(200)         NULL,
   LIST_DIALOG_ID       NUMERIC(18,0)        NULL,
   LIST_DIALOG_NAME     VARCHAR(200)         NULL,
   FIELD                VARCHAR(1000)        NULL,
   CONSTRAINT PK_BPM_FORM_DIALOG_COMBINATE PRIMARY KEY NONCLUSTERED (ID)
)
go

ALTER TABLE BPM_FORM_DIALOG_COMBINATE
   ADD CONSTRAINT AK_KEY_3_BPM_FORM UNIQUE (ALIAS)
go

CREATE TABLE FORM_DEF_TREE (
   ID                   NUMERIC(18)          NOT NULL,
   NAME                 VARCHAR(100)         NULL,
   ALIAS                VARCHAR(50)          NULL,
   TREE_ID              VARCHAR(100)         NULL,
   PARENT_ID            VARCHAR(100)         NULL,
   DISPLAY_FIELD        VARCHAR(100)         NULL,
   LOAD_TYPE            SMALLINT             NULL,
   ROOT_ID              VARCHAR(255)         NULL,
   FORM_KEY             VARCHAR(50)          NULL,
   CONSTRAINT PK_FORM_DEF_TREE PRIMARY KEY NONCLUSTERED (ID)
)
go
ALTER TABLE FORM_DEF_TREE
   ADD CONSTRAINT UN_FORM_DEF_TREE UNIQUE (ALIAS)
go


CREATE TABLE FORM_DEF_COMBINATE (
   ID                   INT                  NOT NULL DEFAULT 0,
   NAME                 VARCHAR(200)         NULL,
   ALIAS                VARCHAR(100)         NULL,
   TREE_DIALOG_ID       INT                  NULL,
   TREE_DIALOG_NAME     VARCHAR(200)         NULL,
   FORM_DEF_ID          INT                  NULL,
   FORM_DEF_NAME        VARCHAR(200)         NULL,
   FIELD                TEXT                 NULL,
   CONSTRAINT PK_FORM_DEF_COMBINATE PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '树对话框ID',
   'user', @CURRENTUSER, 'table', 'FORM_DEF_COMBINATE', 'column', 'TREE_DIALOG_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单ID 注意 表单需要有业务数据模板才行',
   'user', @CURRENTUSER, 'table', 'FORM_DEF_COMBINATE', 'column', 'FORM_DEF_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '树数据返回数据对应列表数据的查询条件',
   'user', @CURRENTUSER, 'table', 'FORM_DEF_COMBINATE', 'column', 'FIELD'
go

ALTER TABLE FORM_DEF_COMBINATE
   ADD CONSTRAINT ALIAS_UNIQUE UNIQUE (ALIAS)
go


/*==============================================================*/
/* Table: SYS_BUS_EVENT                                         */
/*==============================================================*/
CREATE TABLE SYS_BUS_EVENT (
   ID                   INT                  NOT NULL DEFAULT 0,
   FORMKEY              VARCHAR(50)          NULL DEFAULT NULL,
   JS_PRE_SCRIPT        VARCHAR(4000)        NULL DEFAULT '',
   JS_AFTER_SCRIPT      VARCHAR(2000)        NULL DEFAULT '',
   PRE_SCRIPT           VARCHAR(2000)        NULL DEFAULT NULL,
   AFTER_SCRIPT         VARCHAR(2000)        NULL DEFAULT NULL,
   CONSTRAINT PK_SYS_BUS_EVENT PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_BUS_EVENT', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单key',
   'user', @CURRENTUSER, 'table', 'SYS_BUS_EVENT', 'column', 'FORMKEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'JS前置脚本',
   'user', @CURRENTUSER, 'table', 'SYS_BUS_EVENT', 'column', 'JS_PRE_SCRIPT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'js后置脚本',
   'user', @CURRENTUSER, 'table', 'SYS_BUS_EVENT', 'column', 'JS_AFTER_SCRIPT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'JAVA前置脚本',
   'user', @CURRENTUSER, 'table', 'SYS_BUS_EVENT', 'column', 'PRE_SCRIPT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'java后置脚本',
   'user', @CURRENTUSER, 'table', 'SYS_BUS_EVENT', 'column', 'AFTER_SCRIPT'
go


/*==============================================================*/
/* Table: BPM_NEWFLOW_TRIGGER                                   */
/*==============================================================*/
CREATE TABLE BPM_NEWFLOW_TRIGGER (
   ID                   NUMERIC(20,0)        NOT NULL,
   NAME                 VARCHAR(255)         NULL,
   NODEID               VARCHAR(255)         NULL,
   ACTION               VARCHAR(50)          NULL,
   FLOWKEY              VARCHAR(255)         NULL,
   TRIGGERFLOWKEY       VARCHAR(255)         NULL,
   TRIGGERFLOWNAME      VARCHAR(500)         NULL,
   JSONMAPING           TEXT                 NULL,
   TRIGGERJSON          TEXT                 NULL,
   NOTE                 VARCHAR(2000)        NULL,
   CONSTRAINT PK_BPM_NEWFLOW_TRIGGER PRIMARY KEY NONCLUSTERED (ID)
)
go

CREATE TABLE BPM_NODEMSG_TEMPLATE (
   ID                   NUMERIC(20,0)        NOT NULL,
   DEFID                NUMERIC(20,0)        NULL,
   PARENTDEFID          NUMERIC(20,0)        NULL,
   NODEID               VARCHAR(20)          NULL,
   TITLE                VARCHAR(200)         NULL,
   HTML                 TEXT                 NULL,
   TEXT                 TEXT                 NULL,
   CONSTRAINT PK_BPM_NODEMSG_TEMPLATE PRIMARY KEY NONCLUSTERED (ID)
)
go


/*==============================================================*/
/* Table: SYS_EXCEL_TEMP                                        */
/*==============================================================*/
CREATE TABLE SYS_EXCEL_TEMP (
   ID                   NUMERIC(20,0)        NOT NULL,
   TEMP_CODE            VARCHAR(100)         NOT NULL,
   TEMP_NAME            VARCHAR(100)         NULL,
   TEMP_DES             VARCHAR(500)         NULL,
   TEMP_DES_HEIGHT      NUMERIC(4,0)         NULL,
   MEMO                 VARCHAR(500)         NULL,
   TEMP_DATA_SAMPLE     TEXT                 NULL,
   CONSTRAINT PK_SYS_EXCEL_TEMP PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_TEMP', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模板代码',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_TEMP', 'column', 'TEMP_CODE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模板名称',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_TEMP', 'column', 'TEMP_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模板填写说明',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_TEMP', 'column', 'TEMP_DES'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '填写说明行高',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_TEMP', 'column', 'TEMP_DES_HEIGHT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_TEMP', 'column', 'MEMO'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模板样例数据',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_TEMP', 'column', 'TEMP_DATA_SAMPLE'
go
/*==============================================================*/
/* Table: SYS_EXCEL_TEMP_DETAIL                                 */
/*==============================================================*/
CREATE TABLE SYS_EXCEL_TEMP_DETAIL (
   ID                   NUMERIC(20,0)        NOT NULL,
   TEMP_ID              NUMERIC(20,0)        NULL,
   COLUMN_NAME          VARCHAR(100)         NULL,
   COLUMN_TYPE          NUMERIC(4,0)         NULL,
   COLUMN_LEN           NUMERIC(4,0)         NULL,
   SHOW_INDEX           NUMERIC(4,0)         NULL,
   CONSTRAINT PK_SYS_EXCEL_TEMP_DETAIL PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_TEMP_DETAIL', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模板ID',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_TEMP_DETAIL', 'column', 'TEMP_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '列名称',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_TEMP_DETAIL', 'column', 'COLUMN_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据类型',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_TEMP_DETAIL', 'column', 'COLUMN_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '列长',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_TEMP_DETAIL', 'column', 'COLUMN_LEN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '显示顺序',
   'user', @CURRENTUSER, 'table', 'SYS_EXCEL_TEMP_DETAIL', 'column', 'SHOW_INDEX'
go


/*==============================================================*/
/* Table: SYS_QUERY_SQLDEF                                      */
/*==============================================================*/
CREATE TABLE SYS_QUERY_SQLDEF (
   ID                   NUMERIC(18,0)        NOT NULL,
   NAME                 VARCHAR(50)          NULL,
   SQL_                 VARCHAR(2000)        NULL,
   DSNAME               VARCHAR(50)          NULL,
   BUTTON_DEF           VARCHAR(1000)        NULL,
   ALIAS                VARCHAR(50)          NULL,
   CATEGORYID           NUMERIC(18,0)        NULL,
   SUPPORT_TAB          SMALLINT             NULL,
   CONSTRAINT PK_SYS_QUERY_SQLDEF PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_SQLDEF', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '名称',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_SQLDEF', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'SQL定义',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_SQLDEF', 'column', 'SQL_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据源名称',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_SQLDEF', 'column', 'DSNAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '按纽定义',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_SQLDEF', 'column', 'BUTTON_DEF'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '别名',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_SQLDEF', 'column', 'ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分类ID',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_SQLDEF', 'column', 'CATEGORYID'
go


CREATE TABLE SYS_QUERY_VIEW (
   ID                   NUMERIC(18,0)        NOT NULL,
   SQL_ALIAS            VARCHAR(50)          NULL,
   NAME                 VARCHAR(50)          NULL,
   ALIAS                VARCHAR(50)          NULL,
   CONDITIONS           TEXT                 NULL,
   FILTER_TYPE          SMALLINT             NULL,
   FILTER               TEXT                 NULL,
   BUTTONS              VARCHAR(1000)        NULL,
   INIT_QUERY           SMALLINT             NULL,
   TEMPLATE             TEXT                 NULL,
   SUPPORT_GROUP        SMALLINT             NULL,
   GROUP_SETTING        VARCHAR(400)         NULL,
   PAGE_SIZE            SMALLINT             NULL,
   SHOW_ROWS_NUM        SMALLINT             NULL,
   SN                   NUMERIC(18,0)        NULL,
   NEED_PAGE            SMALLINT             NULL,
   TEMPLATEALIAS        VARCHAR(50)          NULL,
   CONSTRAINT PK_SYS_QUERY_VIEW PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'sql别名',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'SQL_ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '视图名称',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '视图别名',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '查询条件定义',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'CONDITIONS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '过滤器类型',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'FILTER_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '过滤器',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'FILTER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '按纽定义',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'BUTTONS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否初始化查询',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'INIT_QUERY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '模版定义',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'TEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否支持分组',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'SUPPORT_GROUP'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分组设定',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'GROUP_SETTING'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分页大小',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'PAGE_SIZE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '显示行号',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'SHOW_ROWS_NUM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'SN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否分页',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'NEED_PAGE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '摸版别名',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_VIEW', 'column', 'TEMPLATEALIAS'
go
CREATE TABLE SYS_QUERY_METAFIELD (
   ID                   NUMERIC(18,0)        NOT NULL,
   SQL_ID               NUMERIC(18,0)        NULL,
   NAME                 VARCHAR(50)          NULL,
   FIELD_NAME           VARCHAR(50)          NULL,
   FIELD_DESC           VARCHAR(100)         NULL,
   IS_SHOW              SMALLINT             NULL,
   IS_SEARCH            SMALLINT             NULL,
   CONTROL_TYPE         SMALLINT             NULL,
   DATA_TYPE            VARCHAR(10)          NULL,
   IS_VIRTUAL           SMALLINT             NULL,
   VIRTUAL_FROM         SMALLINT             NULL,
   RESULT_FROM_TYPE     VARCHAR(10)          NULL,
   RESULT_FROM          VARCHAR(400)         NULL,
   ALARM_SETTING        VARCHAR(400)         NULL,
   DATE_FORMAT          VARCHAR(40)          NULL,
   URL                  VARCHAR(200)         NULL,
   FORMATER             VARCHAR(1000)        NULL,
   CONTROL_CONTENT      VARCHAR(400)         NULL,
   SN                   SMALLINT             NULL,
   WIDTH                SMALLINT             NULL,
   CONSTRAINT PK_SYS_QUERY_METAFIELD PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'SQL_ID',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'SQL_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '字段名',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '实际字段名',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'FIELD_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '字段备注',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'FIELD_DESC'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否可见',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'IS_SHOW'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否搜索',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'IS_SEARCH'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '控件类型',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'CONTROL_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据类型',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'DATA_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否衍生列',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'IS_VIRTUAL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '衍生列来自列',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'VIRTUAL_FROM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '来自类型',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'RESULT_FROM_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '衍生列配置',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'RESULT_FROM'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '报警设定',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'ALARM_SETTING'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '日期格式',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'DATE_FORMAT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '连接地址',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'URL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '格式化函数',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'FORMATER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '控件内容',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_METAFIELD', 'column', 'CONTROL_CONTENT'
go
CREATE TABLE SYS_QUERY_FIELDSETTING (
   ID                   NUMERIC(18,0)        NOT NULL,
   VIEW_ID              NUMERIC(18,0)        NULL,
   FIELD_NAME           VARCHAR(50)          NULL,
   SORT_ABLE            SMALLINT             NULL,
   DEFAULT_SORT         SMALLINT             NULL,
   SORT_SEQ             VARCHAR(10)          NULL,
   ALIGN                VARCHAR(10)          NULL,
   FROZEN               SMALLINT             NULL,
   SUMMARY_TYPE         VARCHAR(50)          NULL,
   SUMMARY_TEMPLATE     VARCHAR(200)         NULL,
   HIDDEN               SMALLINT             NULL,
   SN                   SMALLINT             NULL,
   WIDTH                SMALLINT             NULL,
   CONSTRAINT PK_SYS_QUERY_FIELDSETTING PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_FIELDSETTING', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '视图ID',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_FIELDSETTING', 'column', 'VIEW_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '字段名称',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_FIELDSETTING', 'column', 'FIELD_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '允许排序',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_FIELDSETTING', 'column', 'SORT_ABLE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '默认排序',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_FIELDSETTING', 'column', 'DEFAULT_SORT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '默认排序方向',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_FIELDSETTING', 'column', 'SORT_SEQ'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '对齐方式',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_FIELDSETTING', 'column', 'ALIGN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否冻结',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_FIELDSETTING', 'column', 'FROZEN'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '计算类型',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_FIELDSETTING', 'column', 'SUMMARY_TYPE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '计算模版',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_FIELDSETTING', 'column', 'SUMMARY_TEMPLATE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否隐藏',
   'user', @CURRENTUSER, 'table', 'SYS_QUERY_FIELDSETTING', 'column', 'HIDDEN'
go


/*==============================================================*/
/* Table: SYS_HISTORY_DATA                                      */
/*==============================================================*/
CREATE TABLE SYS_HISTORY_DATA (
   ID                   NUMERIC(18,0)        NOT NULL,
   TYPE_                VARCHAR(50)          NULL,
   OBJ_ID               NUMERIC(18,0)        NULL,
   CONTENT              TEXT                 NULL,
   CREATOR              VARCHAR(50)          NULL,
   SUBJECT              VARCHAR(200)         NULL,
   CREATETIME           DATETIME             NULL,
   CONSTRAINT PK_SYS_HISTORY_DATA PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_HISTORY_DATA', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '数据类型',
   'user', @CURRENTUSER, 'table', 'SYS_HISTORY_DATA', 'column', 'TYPE_'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '关联对象ID',
   'user', @CURRENTUSER, 'table', 'SYS_HISTORY_DATA', 'column', 'OBJ_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '存储内容',
   'user', @CURRENTUSER, 'table', 'SYS_HISTORY_DATA', 'column', 'CONTENT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'SYS_HISTORY_DATA', 'column', 'CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'SYS_HISTORY_DATA', 'column', 'CREATETIME'
go


CREATE TABLE SYS_BULLETIN_TEMPLATE (
   ID                   NUMERIC(20,0)        NOT NULL,
   NAME                 VARCHAR(50)          NULL DEFAULT NULL,
   ALIAS                VARCHAR(20)          NULL DEFAULT NULL,
   TEMPLATE             TEXT                 NULL
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN_TEMPLATE', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '名称',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN_TEMPLATE', 'column', 'NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '别名',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN_TEMPLATE', 'column', 'ALIAS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'html内容',
   'user', @CURRENTUSER, 'table', 'SYS_BULLETIN_TEMPLATE', 'column', 'TEMPLATE'
go

ALTER TABLE SYS_BULLETIN_TEMPLATE
   ADD CONSTRAINT BULLETIN_TEMPLETE_UNIQUE UNIQUE (ALIAS)
go

CREATE TABLE SYS_READ_RECORD (
   ID                   NUMERIC(18,0)                 NOT NULL,
   SOURCE               VARCHAR(50)          NULL,
   GROUPID              NUMERIC(18,0)                   NULL,
   OBJECTID             NUMERIC(18,0)                   NOT NULL,
   USERID               NUMERIC(18,0)                   NOT NULL,
   CREATETIME           DATETIME             NOT NULL,
   CONSTRAINT PK_SYS_READ_RECORD PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '来源；eg:公告：BULLETINID',
   'user', @CURRENTUSER, 'table', 'SYS_READ_RECORD', 'column', 'SOURCE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分组ID；删除时可以删除一组，如任务存放流程实例id,栏目ID',
   'user', @CURRENTUSER, 'table', 'SYS_READ_RECORD', 'column', 'GROUPID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '对象ID',
   'user', @CURRENTUSER, 'table', 'SYS_READ_RECORD', 'column', 'OBJECTID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户ID',
   'user', @CURRENTUSER, 'table', 'SYS_READ_RECORD', 'column', 'USERID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '阅读时间',
   'user', @CURRENTUSER, 'table', 'SYS_READ_RECORD', 'column', 'CREATETIME'
go

CREATE TABLE SYS_PWD_STRATEGY (
   ID                   INT                  NOT NULL DEFAULT 0,
   INIT_PWD             VARCHAR(50)          NULL DEFAULT NULL,
   FORCE_CHANGE_INIT_PWD SMALLINT             NULL DEFAULT NULL,
   PWD_RULE             SMALLINT             NULL DEFAULT NULL,
   PWD_LENGTH           SMALLINT             NULL DEFAULT NULL,
   VALIDITY             SMALLINT             NULL DEFAULT NULL,
   HANDLE_OVERDUE       SMALLINT             NULL DEFAULT NULL,
   OVERDUE_REMIND       SMALLINT             NULL DEFAULT NULL,
   VERIFY_CODE_APPEAR   SMALLINT             NULL DEFAULT NULL,
   ERR_LOCK_ACCOUNT     SMALLINT             NULL DEFAULT NULL,
   ENABLE_              SMALLINT             NULL DEFAULT NULL,
   DESC_                TEXT                 NULL,
   CONSTRAINT PK_SYS_PWD_STRATEGY PRIMARY KEY NONCLUSTERED (ID)
)
go


CREATE TABLE SYS_LOGIN_LOG (
   ID                   NUMERIC(20,0)                   NOT NULL DEFAULT 0,
   ACCOUNT              VARCHAR(200)         NULL DEFAULT NULL,
   LOGINTIME            DATETIME             NULL DEFAULT NULL,
   IP                   VARCHAR(200)         NULL DEFAULT NULL,
   STATUS               SMALLINT             NULL DEFAULT NULL,
   DESC_                TEXT                 NULL,
   CONSTRAINT PK_SYS_LOGIN_LOG PRIMARY KEY NONCLUSTERED (ID)
)
go


/*==============================================================*/
/* Table: OA_LINKMAN                                            */
/*==============================================================*/
CREATE TABLE OA_LINKMAN (
   ID                   NUMERIC(18,0)                 NOT NULL,
   NAME                 VARCHAR(50)          NULL DEFAULT NULL,
   SEX                  VARCHAR(8)           NULL DEFAULT NULL,
   PHONE                VARCHAR(50)          NULL DEFAULT NULL,
   EMAIL                VARCHAR(50)          NULL DEFAULT NULL,
   COMPANY              VARCHAR(50)          NULL DEFAULT NULL,
   JOB                  VARCHAR(20)          NULL DEFAULT NULL,
   ADDRESS              VARCHAR(50)          NULL DEFAULT NULL,
   CREATETIME           DATETIME             NULL DEFAULT NULL,
   STATUS               SMALLINT             NULL DEFAULT 1,
   USERID               NUMERIC(18,0)              NULL DEFAULT NULL,
   CONSTRAINT PK_OA_LINKMAN PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '性别',
   'user', @CURRENTUSER, 'table', 'OA_LINKMAN', 'column', 'SEX'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '电话',
   'user', @CURRENTUSER, 'table', 'OA_LINKMAN', 'column', 'PHONE'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '邮箱',
   'user', @CURRENTUSER, 'table', 'OA_LINKMAN', 'column', 'EMAIL'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '公司',
   'user', @CURRENTUSER, 'table', 'OA_LINKMAN', 'column', 'COMPANY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '工作',
   'user', @CURRENTUSER, 'table', 'OA_LINKMAN', 'column', 'JOB'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '地址',
   'user', @CURRENTUSER, 'table', 'OA_LINKMAN', 'column', 'ADDRESS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'OA_LINKMAN', 'column', 'CREATETIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '状态,1为启用，0为禁用',
   'user', @CURRENTUSER, 'table', 'OA_LINKMAN', 'column', 'STATUS'
go

/*==============================================================*/
/* Table: SYS_MSG_LINKMAN_GROUP                                 */
/*==============================================================*/
CREATE TABLE SYS_MSG_LINKMAN_GROUP (
   ID                   NUMERIC(20,0)        NOT NULL,
   GROUP_NAME           VARCHAR(200)         NULL,
   USER_IDS             VARCHAR(2000)        NULL,
   USERS                VARCHAR(2000)        NULL,
   CREATOR_ID           NUMERIC(20,0)        NULL,
   CREATE_TIME          DATETIME             NULL,
   CONSTRAINT PK_SYS_MSG_LINKMAN_GROUP PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '主键',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_LINKMAN_GROUP', 'column', 'ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组名',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_LINKMAN_GROUP', 'column', 'GROUP_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '常用联系人ID',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_LINKMAN_GROUP', 'column', 'USER_IDS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '常用联系人',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_LINKMAN_GROUP', 'column', 'USERS'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_LINKMAN_GROUP', 'column', 'CREATOR_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'SYS_MSG_LINKMAN_GROUP', 'column', 'CREATE_TIME'
go


/*==============================================================*/
/* Table: BPM_MOBILE_FORM_DEF                                   */
/*==============================================================*/
CREATE TABLE BPM_MOBILE_FORM_DEF (
   ID                   NUMERIC(18,0)        NOT NULL,
   VERSION              NUMERIC(8,0)         NULL DEFAULT 1,
   FORM_KEY             VARCHAR(50)          NULL,
   FORM_HTML            TEXT                 NULL,
   TABLE_ID             NUMERIC(18,0)        NULL,
   TABLE_NAME           VARCHAR(50)          NULL,
   SUBJECT              VARCHAR(255)         NULL,
   CREATE_BY            NUMERIC(18,0)        NULL,
   CREATOR              VARCHAR(50)          NULL,
   CREATE_TIME          DATETIME             NULL,
   IS_DEFAULT           NUMERIC(8,0)         NULL,
   IS_PUBLISHED         NUMERIC(8,0)         NULL DEFAULT 0,
   PUBLISHER            VARCHAR(50)          NULL,
   PUBLISH_BY           NUMERIC(18,0)        NULL,
   PUBLISH_TIME         DATETIME             NULL,
   UPDATOR              VARCHAR(50)          NULL,
   UPDATE_BY            NUMERIC(18,0)        NULL,
   UPDATE_TIME          DATETIME             NULL,
   CATEGORY_ID          NUMERIC(18,0)        NULL,
   TEMPLATE				TEXT 		         NULL,
   CONSTRAINT PK_BPM_MOBILE_FORM_DEF PRIMARY KEY NONCLUSTERED (ID)
)
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '版本',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'VERSION'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单KEY',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'FORM_KEY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单HTML',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'FORM_HTML'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表ID',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'TABLE_ID'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表名',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'TABLE_NAME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '表单主题',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'SUBJECT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人ID',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'CREATE_BY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建人',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'CREATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '创建时间',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'CREATE_TIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否默认版本',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'IS_DEFAULT'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否发布',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'IS_PUBLISHED'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发布人',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'PUBLISHER'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发布人ID',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'PUBLISH_BY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发布时间',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'PUBLISH_TIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '更新人',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'UPDATOR'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '更新人ID',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'UPDATE_BY'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '最后更新时间',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'UPDATE_TIME'
go

DECLARE @CURRENTUSER SYSNAME
SELECT @CURRENTUSER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分类',
   'user', @CURRENTUSER, 'table', 'BPM_MOBILE_FORM_DEF', 'column', 'CATEGORY_ID'
go