IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_BIZ_INFO' AND KSQL_COL_NAME IN ('FMULTICOMPANYID'))
ALTER TABLE T_ER_BIZ_INFO ADD (FMULTICOMPANYID CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_TRIPSYNC_DATAMAPPING' AND KSQL_COL_NAME IN ('FOUTDATANUMBER'))
ALTER TABLE T_ER_TRIPSYNC_DATAMAPPING ADD (FOUTDATANUMBER VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_TRIPCOMPANYINFO')
CREATE TABLE T_ER_TRIPCOMPANYINFO (
  FENTRYID BIGINT DEFAULT 0 NOT NULL,
  FID BIGINT DEFAULT 0 NOT NULL,
  FSEQ INT DEFAULT 0 NOT NULL,
  FACCOUNTORG BIGINT DEFAULT 0 NOT NULL,
  FCOMPANYID VARCHAR(100) DEFAULT ' ' NOT NULL,
  FSIGNKEY VARCHAR(255) DEFAULT ' ' NOT NULL,
  FSTAFFCODE VARCHAR(50) DEFAULT ' ' NOT NULL,
  FREALNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);

EXEC P_ALTERPK 'PK_T_ER_TRIPCOMPANYINFO', 'T_ER_TRIPCOMPANYINFO', 'FENTRYID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'T_ER_TRIPCOMPANYINFO_FID') CREATE INDEX T_ER_TRIPCOMPANYINFO_FID ON T_ER_TRIPCOMPANYINFO ( FID ,FSEQ );