/** 增加选择范围分录、发票因素默认字段  ***/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_EXPENSEITEMRANGE')
CREATE TABLE T_ER_EXPENSEITEMRANGE
(
    FID               BIGINT  DEFAULT 0   NOT NULL,
    FENTRYID          BIGINT  DEFAULT 0   NOT NULL,
    FSEQ              INT     DEFAULT 0   NOT NULL,
    FENTRYEXPENSEITEM BIGINT  DEFAULT 0   NOT NULL,
    FENTRYTRIPITEM    BIGINT  DEFAULT 0   NOT NULL,
    FISDEFAULT        CHAR(1) DEFAULT '0' NOT NULL
);

EXEC P_ALTERPK 'PK_T_ER_EXPENSEITEMRANGE', 'T_ER_EXPENSEITEMRANGE', 'FENTRYID', '0';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_ER_EXPENSEITEMRANGE' AND KSQL_INDNAME = 'IDX_ER_EXPENSEITEMRANGE_FID') CREATE
CLUSTERED INDEX IDX_ER_EXPENSEITEMRANGE_FID ON T_ER_EXPENSEITEMRANGE ( FID );
