IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_EXPENSEDETAIL_A' AND KSQL_COL_NAME IN ('FTRIPBOOKAMOUNT'))
ALTER TABLE T_ER_EXPENSEDETAIL_A ADD (FTRIPBOOKAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_EXPENSEDETAIL_A' AND KSQL_COL_NAME IN ('FTRIPBOOKCURAMOUNT'))
ALTER TABLE T_ER_EXPENSEDETAIL_A ADD (FTRIPBOOKCURAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_EXPENSEDETAIL_A' AND KSQL_COL_NAME IN ('FISEXISTMONTHLY'))
ALTER TABLE T_ER_EXPENSEDETAIL_A ADD (FISEXISTMONTHLY CHAR(1) DEFAULT '0' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL' AND KSQL_COL_NAME IN ('FMONTHSETTLEAMOUNT'))
ALTER TABLE T_ER_DAILYREIMBURSEBILL ADD (FMONTHSETTLEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_DAILYREMORDERENTRY')
CREATE TABLE T_ER_DAILYREMORDERENTRY (
 FID BIGINT DEFAULT 0 NOT NULL,
 FENTRYID BIGINT DEFAULT 0 NOT NULL,
 FSEQ INT DEFAULT 0 NOT NULL,
 FSERVER VARCHAR(50) DEFAULT ' ' NOT NULL,
 FOPERATIONTYPE VARCHAR(10) DEFAULT ' ' NOT NULL,
 FOABILLNUM NVARCHAR(255) DEFAULT ' ' NOT NULL,
 FORDERDATE DATETIME,
 FSOURCEBOOKEDID BIGINT DEFAULT 0 NOT NULL,
 FORDERNUMBER VARCHAR(255) DEFAULT ' ' NOT NULL,
 FPARENTORDERNUM VARCHAR(255) DEFAULT ' ' NOT NULL,
 FORDERTYPE CHAR(1) DEFAULT ' ' NOT NULL,
 FORDERSTATUSSTR NVARCHAR(50) DEFAULT ' ' NOT NULL,
 FTICKETSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
 FTOTALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
 FTICKETPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
 FSERVICEFEE DECIMAL(23,10) DEFAULT 0 NOT NULL,
 FREFUNDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
 FASSURANCEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
 FAIRPORTPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
 FFUELPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
 FENDORSEMENTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
 FTRAVELERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
 FFROMPLACE NVARCHAR(2000) DEFAULT ' ' NOT NULL,
 FTOPLACE NVARCHAR(2000) DEFAULT ' ' NOT NULL,
 FBEGINTIME DATETIME,
 FENDTIME DATETIME,
 FORDERBOOKEDDEPT BIGINT DEFAULT 0 NOT NULL,
 FORDERCOMPANY BIGINT DEFAULT 0 NOT NULL,
 FORDERCOSTDEPT BIGINT DEFAULT 0 NOT NULL,
 FORDERCOSTCOMPANY BIGINT DEFAULT 0 NOT NULL,
 FORDERDEDUCTIBLETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
 FTICKETPRICEDEDUCTIBLETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
 FSERVICEFEEDEDUCTIBLETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
 FORDERCURRENCY BIGINT DEFAULT 0 NOT NULL,
 FORDEXPENSEENTRYID BIGINT DEFAULT 0 NOT NULL,
 FORDERFORMID VARCHAR(255) DEFAULT ' ' NOT NULL
);

EXEC P_ALTERPK 'PK_ER_DAILYREMORDERENTRY', 'T_ER_DAILYREMORDERENTRY', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_DAILYREIM_ORDER_FID') CREATE INDEX IDX_ER_DAILYREIM_ORDER_FID ON T_ER_DAILYREMORDERENTRY ( FID );