/**Begin D:\PDM_UPGRADE\pdm1\IM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MREQOUTSNENTRY') 
 CREATE TABLE T_IM_MDC_MREQOUTSNENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSERIALNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSERIALCOMMENT NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSERIALID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MFTREQOUTENTRY') 
 CREATE TABLE T_IM_MDC_MFTREQOUTENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALMASTERID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT2NDID BIGINT DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FQTYUNIT2ND DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENTRYORGID BIGINT DEFAULT 0 NOT NULL,
FQTYUNIT3RD DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT3RDID BIGINT DEFAULT 0 NOT NULL,
FUNITRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT2NDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT3RDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAUXPTYID BIGINT DEFAULT 0 NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FLOCATIONID BIGINT DEFAULT 0 NOT NULL,
FLOTID BIGINT DEFAULT 0 NOT NULL,
FLOTNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FPRODUCEDATE DATETIME,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FEXPIRYDATE DATETIME,
FENTRYCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FKEEPERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOWNERID BIGINT DEFAULT 0 NOT NULL,
FKEEPERID BIGINT DEFAULT 0 NOT NULL,
FINVSTATUSID BIGINT DEFAULT 0 NOT NULL,
FINVTYPEID BIGINT DEFAULT 0 NOT NULL,
FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL,
FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL,
FOUTOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOUTOWNERID BIGINT DEFAULT 0 NOT NULL,
FOUTKEEPERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOUTKEEPERID BIGINT DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISFREEGIFT CHAR(1) DEFAULT '0' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MFTMANUINBILL_L') 
 CREATE TABLE T_IM_MDC_MFTMANUINBILL_L (
FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(512) DEFAULT ' '
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MFTMANUINENTRY') 
 CREATE TABLE T_IM_MDC_MFTMANUINENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT2NDID BIGINT DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FQTYUNIT2ND DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTYUNIT3RD DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT3RDID BIGINT DEFAULT 0 NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FLOCATIONID BIGINT DEFAULT 0 NOT NULL,
FINVSTATUSID BIGINT DEFAULT 0 NOT NULL,
FLOTID BIGINT DEFAULT 0 NOT NULL,
FPRODUCEDATE DATETIME,
FEXPIRYDATE DATETIME,
FENTRYCOMMENT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FKEEPERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOWNERID BIGINT DEFAULT 0 NOT NULL,
FKEEPERID BIGINT DEFAULT 0 NOT NULL,
FLOTNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FUNIT2NDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT3RDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAUXPTYID BIGINT DEFAULT 0 NOT NULL,
FINVTYPEID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FMATERIALMASTERID BIGINT DEFAULT 0 NOT NULL,
FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL,
FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL,
FOUTOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOUTOWNERID BIGINT DEFAULT 0 NOT NULL,
FOUTKEEPERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOUTKEEPERID BIGINT DEFAULT 0 NOT NULL,
FMAINDEPTID BIGINT DEFAULT 0 NOT NULL,
FPRICES DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNTS DECIMAL(23,10) DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MFTMANUINENTRY_X') 
 CREATE TABLE T_IM_MDC_MFTMANUINENTRY_X (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MFTMANUINSNENTRY') 
 CREATE TABLE T_IM_MDC_MFTMANUINSNENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSERIALNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSERIALCOMMENT NVARCHAR(512) DEFAULT ' ' NOT NULL,
FSERIALID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MFTREQOUTBILL_L') 
 CREATE TABLE T_IM_MDC_MFTREQOUTBILL_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(510) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MFTREQOUTENTRY_R') 
 CREATE TABLE T_IM_MDC_MFTREQOUTENTRY_R (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLENTITY NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSRCBILLID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FMAINBILLNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FMAINBILLID BIGINT DEFAULT 0 NOT NULL,
FMAINBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FMAINBILLENTITY NVARCHAR(100) DEFAULT ' ' NOT NULL,
FMAINBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FRETURNBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINRETURNBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRETURNQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINRETURNQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVMISETTLEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVMISETTLEBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVMIREMAINSETTLEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVMIREMAINSETTLEBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPURCHASEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINPURQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPURCHASEDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINPURAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL,
FMVERSION BIGINT DEFAULT 0 NOT NULL,
FMANUBILL NVARCHAR(100) DEFAULT ' ' NOT NULL,
FMANUBILLID BIGINT DEFAULT 0 NOT NULL,
FMANUENTRY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMANUENTRYID BIGINT DEFAULT 0 NOT NULL,
FOPERATION NVARCHAR(100) DEFAULT ' ' NOT NULL,
FOPERATIONID BIGINT DEFAULT 0 NOT NULL,
FWORKCENTER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FWORKCENTERID BIGINT DEFAULT 0 NOT NULL,
FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MFTMANUINENTRY_R') 
 CREATE TABLE T_IM_MDC_MFTMANUINENTRY_R (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLENTITY NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSRCBILLID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL,
FMVERSION BIGINT DEFAULT 0 NOT NULL,
FRETURNQTYS DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRETURNBASEQTYS DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINRETURNBASEQTYS DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINRETURNQTYS DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MFTMANUINENTRY_M') 
 CREATE TABLE T_IM_MDC_MFTMANUINENTRY_M (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FMANUBILL NVARCHAR(100) DEFAULT ' ' NOT NULL,
FMANUBILLID BIGINT DEFAULT 0 NOT NULL,
FMANUENTRY NVARCHAR(100) DEFAULT ' ' NOT NULL,
FMANUENTRYID BIGINT DEFAULT 0 NOT NULL,
FWORKCENTER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FWORKCENTERID BIGINT DEFAULT 0 NOT NULL,
FWORKSHOP NVARCHAR(100) DEFAULT ' ' NOT NULL,
FWORKSHOPID BIGINT DEFAULT 0 NOT NULL,
FMAINBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FMAINBILLENTITY NVARCHAR(100) DEFAULT ' ' NOT NULL,
FMAINBILLID BIGINT DEFAULT 0 NOT NULL,
FMAINBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FPRODUCTTYPE CHAR(1) DEFAULT '0' NOT NULL,
FQUALITYSTATUS CHAR(1) DEFAULT '0' NOT NULL,
FRECEIVALQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIVEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMATERIALATTR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISCOPY CHAR(1) DEFAULT '0' NOT NULL,
FMAINBILLNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MFTMANUINBILL') 
 CREATE TABLE T_IM_MDC_MFTMANUINBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(60) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) DEFAULT 'A' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBILLTYPEID BIGINT DEFAULT 0 NOT NULL,
FBIZORGID BIGINT DEFAULT 0 NOT NULL,
FBIZDEPTID BIGINT DEFAULT 0 NOT NULL,
FDEPTID BIGINT DEFAULT 0 NOT NULL,
FOPERATORGROUPID BIGINT DEFAULT 0 NOT NULL,
FOPERATORID BIGINT DEFAULT 0 NOT NULL,
FBIZOPERATORID BIGINT DEFAULT 0 NOT NULL,
FBIZTIMES DATETIME,
FBIZTYPEIDS BIGINT DEFAULT 0 NOT NULL,
FINVSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FBILLCRETYPE CHAR(1) DEFAULT '0' NOT NULL,
FSETTLECURRENCYID BIGINT DEFAULT 0 NOT NULL,
FDOCTYPE CHAR(1) DEFAULT '0' NOT NULL,
FCOSTCENTERID BIGINT DEFAULT 0 NOT NULL,
FSHIPPERID BIGINT DEFAULT 0 NOT NULL,
FPRODUCTIONORGID BIGINT DEFAULT 0 NOT NULL,
FBOOKDATE DATETIME,
FHEADWAREHOUSEID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MFTREQOUTBILL') 
 CREATE TABLE T_IM_MDC_MFTREQOUTBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBILLTYPEID BIGINT DEFAULT 0 NOT NULL,
FBIZORGID BIGINT DEFAULT 0 NOT NULL,
FBIZDEPTID BIGINT DEFAULT 0 NOT NULL,
FDEPTID BIGINT DEFAULT 0 NOT NULL,
FOPERATORGROUPID BIGINT DEFAULT 0 NOT NULL,
FOPERATORID BIGINT DEFAULT 0 NOT NULL,
FBIZTIME DATETIME,
FBIZTYPEID BIGINT DEFAULT 0 NOT NULL,
FINVSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSUPPLYOWNER BIGINT DEFAULT 0 NOT NULL,
FSETTLEORG BIGINT DEFAULT 0 NOT NULL,
FREQUSERID BIGINT DEFAULT 0 NOT NULL,
FCOSTCENTERORG BIGINT DEFAULT 0 NOT NULL,
FSETTLECURRENCY BIGINT DEFAULT 0 NOT NULL,
FISVIRTUALBILL CHAR(1) DEFAULT '0' NOT NULL,
FBILLCRETYPE CHAR(1) DEFAULT '0' NOT NULL,
FNEEDTIME DATETIME,
FWORKSHOP NVARCHAR(80) DEFAULT ' ' NOT NULL,
FWORKSHOPID BIGINT DEFAULT 0 NOT NULL,
FWAREHOSUE BIGINT DEFAULT 0 NOT NULL,
FSUPPLIER BIGINT DEFAULT 0 NOT NULL,
FDOCTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBOOKDATE DATETIME
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSDIRBILL' AND KSQL_COL_NAME ='FBOOKDATE') 
 ALTER TABLE T_IM_TRANSDIRBILL ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TYPEADJUST' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_TYPEADJUST ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_STATUSADJUST' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_STATUSADJUST ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_LOTADJUST' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_LOTADJUST ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INITBILL' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_INITBILL ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHEROUTBILL' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_OTHEROUTBILL ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHERINBILL' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_OTHERINBILL ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSOUTBILL' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_TRANSOUTBILL ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSINBILL' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_TRANSINBILL ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PRODUCTINBILL' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_PRODUCTINBILL ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_ADJUSTBILL' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_ADJUSTBILL ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILL' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_PURRECBILL ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILL' AND KSQL_COL_NAME IN ('FACCEPTANCESTATUS')) 
 ALTER TABLE T_IM_PURRECBILL ADD (FACCEPTANCESTATUS CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQOUTBILL' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_MREQOUTBILL ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_ASSEMBBILL' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_ASSEMBBILL ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_LOCATIONTRANSFER' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_LOCATIONTRANSFER ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQBILLENTRY' AND KSQL_COL_NAME IN ('FROWSTATUS')) 
 ALTER TABLE T_IM_MREQBILLENTRY ADD (FROWSTATUS NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQBILLENTRY' AND KSQL_COL_NAME IN ('FUNCONTROLLEDQTY')) 
 ALTER TABLE T_IM_MREQBILLENTRY ADD (FUNCONTROLLEDQTY CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQBILLENTRY' AND KSQL_COL_NAME IN ('FEXCESSRATIO')) 
 ALTER TABLE T_IM_MREQBILLENTRY ADD (FEXCESSRATIO INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQBILLENTRY' AND KSQL_COL_NAME IN ('FSHORTAGERATIO')) 
 ALTER TABLE T_IM_MREQBILLENTRY ADD (FSHORTAGERATIO INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FQUALIFIEDUNIT2ND')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FQUALIFIEDUNIT2ND DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FQUALIFIEDUNIT3RD')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FQUALIFIEDUNIT3RD DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FUNQUALIFIEDUNIT2ND')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FUNQUALIFIEDUNIT2ND DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FUNQUALIFIEDUNIT3RD')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FUNQUALIFIEDUNIT3RD DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FACCEPTANCEENTRYSTATUS')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FACCEPTANCEENTRYSTATUS CHAR(1) DEFAULT '0' NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_IM_TRANSAPPLYENTRY', 'FSRCSYSTEM', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_IM_TRANSAPPLYENTRY', 'FSRCSYSBILLID', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_IM_TRANSAPPLYENTRY', 'FSRCSYSBILLENTRYID', 'NULL', 'NULL', '1001', 'NULL';
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INVBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSTEM')) 
 ALTER TABLE T_IM_INVBILLENTRY_R ADD (FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INVBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLID')) 
 ALTER TABLE T_IM_INVBILLENTRY_R ADD (FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INVBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLENTRYID')) 
 ALTER TABLE T_IM_INVBILLENTRY_R ADD (FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSTEM')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLID')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLENTRYID')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FACCEPTANCEDATE')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FACCEPTANCEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FQUALIFIEDQTY')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FQUALIFIEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FQUALIFIEDBASEQTY')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FQUALIFIEDBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FUNQUALIFIEDQTY')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FUNQUALIFIEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FUNQUALIFIEDBASEQTY')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FUNQUALIFIEDBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FQUALIFIEDUNIT2ND')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FQUALIFIEDUNIT2ND DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FQUALIFIEDUNIT3RD')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FQUALIFIEDUNIT3RD DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FUNQUALIFIEDUNIT2ND')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FUNQUALIFIEDUNIT2ND DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FUNQUALIFIEDUNIT3RD')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FUNQUALIFIEDUNIT3RD DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME IN ('FACCEPTANCEENTRYSTATUS')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FACCEPTANCEENTRYSTATUS CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURINBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSTEM')) 
 ALTER TABLE T_IM_PURINBILLENTRY_R ADD (FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURINBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLID')) 
 ALTER TABLE T_IM_PURINBILLENTRY_R ADD (FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURINBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLENTRYID')) 
 ALTER TABLE T_IM_PURINBILLENTRY_R ADD (FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHERINBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSTEM')) 
 ALTER TABLE T_IM_OTHERINBILLENTRY_R ADD (FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHERINBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLID')) 
 ALTER TABLE T_IM_OTHERINBILLENTRY_R ADD (FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHERINBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLENTRYID')) 
 ALTER TABLE T_IM_OTHERINBILLENTRY_R ADD (FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PRODUCTINBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSTEM')) 
 ALTER TABLE T_IM_PRODUCTINBILLENTRY_R ADD (FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PRODUCTINBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLID')) 
 ALTER TABLE T_IM_PRODUCTINBILLENTRY_R ADD (FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PRODUCTINBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLENTRYID')) 
 ALTER TABLE T_IM_PRODUCTINBILLENTRY_R ADD (FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQBILLENTRY' AND KSQL_COL_NAME IN ('FSRCSYSTEM')) 
 ALTER TABLE T_IM_MREQBILLENTRY ADD (FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQBILLENTRY' AND KSQL_COL_NAME IN ('FSRCSYSBILLID')) 
 ALTER TABLE T_IM_MREQBILLENTRY ADD (FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQBILLENTRY' AND KSQL_COL_NAME IN ('FSRCSYSBILLENTRYID')) 
 ALTER TABLE T_IM_MREQBILLENTRY ADD (FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQOUTBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSTEM')) 
 ALTER TABLE T_IM_MREQOUTBILLENTRY_R ADD (FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQOUTBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLID')) 
 ALTER TABLE T_IM_MREQOUTBILLENTRY_R ADD (FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQOUTBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLENTRYID')) 
 ALTER TABLE T_IM_MREQOUTBILLENTRY_R ADD (FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHEROUTBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSTEM')) 
 ALTER TABLE T_IM_OTHEROUTBILLENTRY_R ADD (FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHEROUTBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLID')) 
 ALTER TABLE T_IM_OTHEROUTBILLENTRY_R ADD (FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHEROUTBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLENTRYID')) 
 ALTER TABLE T_IM_OTHEROUTBILLENTRY_R ADD (FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSDIRBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSTEM')) 
 ALTER TABLE T_IM_TRANSDIRBILLENTRY_R ADD (FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSDIRBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLID')) 
 ALTER TABLE T_IM_TRANSDIRBILLENTRY_R ADD (FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSDIRBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLENTRYID')) 
 ALTER TABLE T_IM_TRANSDIRBILLENTRY_R ADD (FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSOUTBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSTEM')) 
 ALTER TABLE T_IM_TRANSOUTBILLENTRY_R ADD (FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSOUTBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLID')) 
 ALTER TABLE T_IM_TRANSOUTBILLENTRY_R ADD (FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSOUTBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLENTRYID')) 
 ALTER TABLE T_IM_TRANSOUTBILLENTRY_R ADD (FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSINBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSTEM')) 
 ALTER TABLE T_IM_TRANSINBILLENTRY_R ADD (FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSINBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLID')) 
 ALTER TABLE T_IM_TRANSINBILLENTRY_R ADD (FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSINBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLENTRYID')) 
 ALTER TABLE T_IM_TRANSINBILLENTRY_R ADD (FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SALOUTBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSTEM')) 
 ALTER TABLE T_IM_SALOUTBILLENTRY_R ADD (FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SALOUTBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLID')) 
 ALTER TABLE T_IM_SALOUTBILLENTRY_R ADD (FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SALOUTBILLENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLENTRYID')) 
 ALTER TABLE T_IM_SALOUTBILLENTRY_R ADD (FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSAPPLYENTRY_Y' AND KSQL_COL_NAME IN ('FSRCSYSTEM')) 
 ALTER TABLE T_IM_TRANSAPPLYENTRY_Y ADD (FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSAPPLYENTRY_Y' AND KSQL_COL_NAME IN ('FSRCSYSBILLID')) 
 ALTER TABLE T_IM_TRANSAPPLYENTRY_Y ADD (FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSAPPLYENTRY_Y' AND KSQL_COL_NAME IN ('FSRCSYSBILLENTRYID')) 
 ALTER TABLE T_IM_TRANSAPPLYENTRY_Y ADD (FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_MFTREQOUTENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLENTRYID')) 
 ALTER TABLE T_IM_MDC_MFTREQOUTENTRY_R ADD (FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_MFTREQOUTENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSTEM')) 
 ALTER TABLE T_IM_MDC_MFTREQOUTENTRY_R ADD (FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_MFTREQOUTENTRY_R' AND KSQL_COL_NAME IN ('FSRCSYSBILLID')) 
 ALTER TABLE T_IM_MDC_MFTREQOUTENTRY_R ADD (FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INITBILLENTRY_R' AND KSQL_COL_NAME ='FSRCSYSTEM') 
 ALTER TABLE T_IM_INITBILLENTRY_R ADD (FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INITBILLENTRY_R' AND KSQL_COL_NAME ='FSRCSYSBILLID') 
 ALTER TABLE T_IM_INITBILLENTRY_R ADD (FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INITBILLENTRY_R' AND KSQL_COL_NAME ='FSRCSYSBILLENTRYID') 
 ALTER TABLE T_IM_INITBILLENTRY_R ADD (FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL );


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SALOUTBILL' AND KSQL_COL_NAME IN ('FTRANSACTEPATHID')) 
 ALTER TABLE T_IM_SALOUTBILL ADD (FTRANSACTEPATHID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SALOUTBILL' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_SALOUTBILL ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURINBILL' AND KSQL_COL_NAME IN ('FTRANSACTEPATHID')) 
 ALTER TABLE T_IM_PURINBILL ADD (FTRANSACTEPATHID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURINBILL' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_PURINBILL ADD (FBOOKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_MFTMANUINBILL' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_MDC_MFTMANUINBILL ADD (FBOOKDATE DATETIME );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_MFTREQOUTBILL' AND KSQL_COL_NAME IN ('FBILLSTATUS')) 
 ALTER TABLE T_IM_MDC_MFTREQOUTBILL ADD (FBILLSTATUS CHAR(1) DEFAULT ' ' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_MFTREQOUTBILL' AND KSQL_COL_NAME IN ('FBOOKDATE')) 
 ALTER TABLE T_IM_MDC_MFTREQOUTBILL ADD (FBOOKDATE DATETIME );

/**End D:\PDM_UPGRADE\pdm1\IM_table.sql **/
