IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_MERGERULECFG')
 CREATE TABLE T_ER_MERGERULECFG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(50) DEFAULT '  ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FENABLE VARCHAR(10) DEFAULT ' ' NOT NULL,
FISENTRYCOSTDEPT CHAR(1) DEFAULT '0' NOT NULL,
FISCOSTCENTER CHAR(1) DEFAULT '0' NOT NULL,
FISEXPENSEITEM CHAR(1) DEFAULT '0' NOT NULL,
FISINVOICETYPE CHAR(1) DEFAULT '0' NOT NULL,
FISOFFSET CHAR(1) DEFAULT '0' NOT NULL,
FISINVOICE CHAR(1) DEFAULT '0' NOT NULL,
FISENTRYCURRENCY CHAR(1) DEFAULT '0' NOT NULL,
FISREIMBURSER CHAR(1) DEFAULT '0' NOT NULL,
FISENTRYCOSTCOMPANY CHAR(1) DEFAULT '0' NOT NULL,
FISTRIP2TO CHAR(1) DEFAULT '0' NOT NULL,
FISTRIPTIME CHAR(1) DEFAULT '0' NOT NULL,
FISTRIPITEM CHAR(1) DEFAULT '0' NOT NULL,
FISTRIP2TRAVELERS CHAR(1) DEFAULT '0' NOT NULL,
FISTRIP2FROM CHAR(1) DEFAULT '0' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FBILLTYPE VARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_MERGERULECFG_L')
 CREATE TABLE T_ER_MERGERULECFG_L (
FPKID VARCHAR(50) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(50) DEFAULT '  ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL
);

 EXEC P_ALTERPK 'PK_ER_MERGERULECFG', 'T_ER_MERGERULECFG', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FNUMBER_ER_MERGERULECFG') CREATE UNIQUE  CLUSTERED INDEX IDX_FNUMBER_ER_MERGERULECFG ON T_ER_MERGERULECFG ( FNUMBER );


 EXEC P_ALTERPK 'PK_ER_MERGERULECFG_L', 'T_ER_MERGERULECFG_L', 'FPKID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FID_ER_MERGERULECFG_L') CREATE  CLUSTERED INDEX IDX_FID_ER_MERGERULECFG_L ON T_ER_MERGERULECFG_L ( FID );
