/*考勤同步出差申请单表*/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_SYNTRIPREQ')
CREATE TABLE T_ER_SYNTRIPREQ (
                                 FID BIGINT DEFAULT 0 NOT NULL,
                                 FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
                                 FDATANO NVARCHAR(80) DEFAULT ' ' NOT NULL,
                                 FTRAVELERID NVARCHAR(80) DEFAULT ' ' NOT NULL,
                                 FOPTYPE NVARCHAR(20) DEFAULT ' ' NOT NULL,
                                 FSYNSTATE NVARCHAR(10) DEFAULT ' ' NOT NULL,
                                 FFAILMESSAGE NVARCHAR(2000) DEFAULT ' ',
                                 FCREATETIME DATETIME,
                                 FMODIFYTIME DATETIME,
                                 FENTRYID NVARCHAR(2000) DEFAULT ' '
);

EXEC P_ALTERPK 'PK_T_ER_SYNTRIPREQ', 'T_ER_SYNTRIPREQ', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_ER_SYNTRIPREQ' AND KSQL_INDNAME = 'IDX_ER_SYNTRIPREQ_FBILLNO') CREATE INDEX IDX_ER_SYNTRIPREQ_FBILLNO ON T_ER_SYNTRIPREQ ( FBILLNO );


/*考勤同步行程明细表*/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_SYNTRIPENTRY')
CREATE TABLE T_ER_SYNTRIPENTRY (
                                   FID BIGINT DEFAULT 0 NOT NULL,
                                   FSTARTDATE DATETIME,
                                   FENDDATE DATETIME,
                                   FCITYNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                   FCITYNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                   FCREATETIME DATETIME
);


EXEC P_ALTERPK 'PK_T_ER_SYNTRIPENTRY', 'T_ER_SYNTRIPENTRY', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_ER_SYNTRIPENTRY' AND KSQL_INDNAME = 'IDX_ER_SYNTRIPENTRY_FCITYNUM') CREATE INDEX IDX_ER_SYNTRIPENTRY_FCITYNUM ON T_ER_SYNTRIPENTRY ( FCITYNUMBER );

