--- 活期计息改造
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_SETTLECENTERINIT' AND KSQL_COL_NAME IN ('FPREINTWAY')) 
 ALTER TABLE T_IFM_SETTLECENTERINIT ADD (FPREINTWAY NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_SETTLECENTERINIT' AND KSQL_COL_NAME IN ('FAUTOWRITEOFF')) 
 ALTER TABLE T_IFM_SETTLECENTERINIT ADD (FAUTOWRITEOFF CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_SETTLECENTERINIT' AND KSQL_COL_NAME IN ('FAUTOREDWRITEOFF')) 
 ALTER TABLE T_IFM_SETTLECENTERINIT ADD (FAUTOREDWRITEOFF CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_CURRENTINTBILL' AND KSQL_COL_NAME IN ('FWRITEOFFPREINTBILLID')) 
 ALTER TABLE T_IFM_CURRENTINTBILL ADD (FWRITEOFFPREINTBILLID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_CURRENTINTBILL' AND KSQL_COL_NAME IN ('FBATCHNOID')) 
 ALTER TABLE T_IFM_CURRENTINTBILL ADD (FBATCHNOID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_CURRENTINTBILL' AND KSQL_COL_NAME IN ('FNOWRITEOFFAMT')) 
 ALTER TABLE T_IFM_CURRENTINTBILL ADD (FNOWRITEOFFAMT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_CURRENTINTBILL' AND KSQL_COL_NAME IN ('FWRITEOFFAMT')) 
 ALTER TABLE T_IFM_CURRENTINTBILL ADD (FWRITEOFFAMT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_CURRENTINTBILL' AND KSQL_COL_NAME IN ('FAFTERCHARGEINSTAMT')) 
 ALTER TABLE T_IFM_CURRENTINTBILL ADD (FAFTERCHARGEINSTAMT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_CURRENTINTBILL' AND KSQL_COL_NAME IN ('FTHISCHARGEINSTAMT')) 
 ALTER TABLE T_IFM_CURRENTINTBILL ADD (FTHISCHARGEINSTAMT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_CURRENTINTBILL' AND KSQL_COL_NAME IN ('FBECHARGEINSTAMT')) 
 ALTER TABLE T_IFM_CURRENTINTBILL ADD (FBECHARGEINSTAMT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_CURRENTINTBILL' AND KSQL_COL_NAME IN ('FWRITEOFFSTATUS')) 
 ALTER TABLE T_IFM_CURRENTINTBILL ADD (FWRITEOFFSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_CURRENTINTBILL' AND KSQL_COL_NAME IN ('FWRITEOFFDATE')) 
 ALTER TABLE T_IFM_CURRENTINTBILL ADD (FWRITEOFFDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTOBJECT' AND KSQL_COL_NAME IN ('FLASTPREINTDATE')) 
 ALTER TABLE T_IFM_INTOBJECT ADD (FLASTPREINTDATE DATETIME );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_INSTWRITEOFF_R') 
 CREATE TABLE T_IFM_INSTWRITEOFF_R (
FID BIGINT DEFAULT 0 NOT NULL,
FBATCHNOID BIGINT DEFAULT 0 NOT NULL,
FPREINSTBILLID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL
);