/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\SM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FCUSTOMERID') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FCUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FLINKMANID') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FLINKMANID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FADDRESS') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FADDRESS NVARCHAR(512) );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FRECCUSTOMERID') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FRECCUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FRECLINKMANID') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FRECLINKMANID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FSETTLECUSTOMERID') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FSETTLECUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FPAYINGCUSTOMERID') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FPAYINGCUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FRECEIVEADDRESS') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FRECEIVEADDRESS NVARCHAR(512) );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FCURRENCYID') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FCURRENCYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FSETTLECURRENCYID') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FSETTLECURRENCYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FSETTLETYPEID') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FSETTLETYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FSETTLEORGID') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FSETTLEORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FEXRATETABLEID') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FEXRATETABLEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FEXCHANGERATE') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FRECCONDITIONID') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FRECCONDITIONID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FISTAX') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FISTAX CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FEXRATEDATE') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FEXRATEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FPAYMODE') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FPAYMODE VARCHAR(30) DEFAULT 'CREDIT' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FCUSTOMERID') 
 ALTER TABLE T_SM_XSALORDER ADD (FCUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FDELIVERYWAYID') 
 ALTER TABLE T_SM_XSALORDER ADD (FDELIVERYWAYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FRECCUSTOMERID') 
 ALTER TABLE T_SM_XSALORDER ADD (FRECCUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FSETTLECUSTOMERID') 
 ALTER TABLE T_SM_XSALORDER ADD (FSETTLECUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FPAYINGCUSTOMERID') 
 ALTER TABLE T_SM_XSALORDER ADD (FPAYINGCUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FLOCATION') 
 ALTER TABLE T_SM_XSALORDER ADD (FLOCATION NVARCHAR(255) );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FRECEIVEADDRESS') 
 ALTER TABLE T_SM_XSALORDER ADD (FRECEIVEADDRESS NVARCHAR(512) );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FRECLINKMANID') 
 ALTER TABLE T_SM_XSALORDER ADD (FRECLINKMANID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FLINKMANID') 
 ALTER TABLE T_SM_XSALORDER ADD (FLINKMANID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FADDRESS') 
 ALTER TABLE T_SM_XSALORDER ADD (FADDRESS NVARCHAR(512) );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FCURRENCYID') 
 ALTER TABLE T_SM_XSALORDER ADD (FCURRENCYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FSETTLECURRENCYID') 
 ALTER TABLE T_SM_XSALORDER ADD (FSETTLECURRENCYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FSETTLETYPEID') 
 ALTER TABLE T_SM_XSALORDER ADD (FSETTLETYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FSETTLEORGID') 
 ALTER TABLE T_SM_XSALORDER ADD (FSETTLEORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FEXRATETABLEID') 
 ALTER TABLE T_SM_XSALORDER ADD (FEXRATETABLEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FEXCHANGERATE') 
 ALTER TABLE T_SM_XSALORDER ADD (FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FRECCONDITIONID') 
 ALTER TABLE T_SM_XSALORDER ADD (FRECCONDITIONID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FTOTALTAXAMOUNT') 
 ALTER TABLE T_SM_XSALORDER ADD (FTOTALTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FTOTALAMOUNT') 
 ALTER TABLE T_SM_XSALORDER ADD (FTOTALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FTOTALALLAMOUNT') 
 ALTER TABLE T_SM_XSALORDER ADD (FTOTALALLAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FISTAX') 
 ALTER TABLE T_SM_XSALORDER ADD (FISTAX CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FCURTOTALAMOUNT') 
 ALTER TABLE T_SM_XSALORDER ADD (FCURTOTALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FCURTOTALALLAMOUNT') 
 ALTER TABLE T_SM_XSALORDER ADD (FCURTOTALALLAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FMARGINLEVEL') 
 ALTER TABLE T_SM_XSALORDER ADD (FMARGINLEVEL DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FMARGIN') 
 ALTER TABLE T_SM_XSALORDER ADD (FMARGIN DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FASSOCIATEMARGIN') 
 ALTER TABLE T_SM_XSALORDER ADD (FASSOCIATEMARGIN DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FASSREFUNDMARGIN') 
 ALTER TABLE T_SM_XSALORDER ADD (FASSREFUNDMARGIN DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FISPAYRATE') 
 ALTER TABLE T_SM_XSALORDER ADD (FISPAYRATE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FEXRATEDATE') 
 ALTER TABLE T_SM_XSALORDER ADD (FEXRATEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FRECEIPTAMOUNT') 
 ALTER TABLE T_SM_XSALORDER ADD (FRECEIPTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FPRERECEIPTAMOUNT') 
 ALTER TABLE T_SM_XSALORDER ADD (FPRERECEIPTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FPAYMODE') 
 ALTER TABLE T_SM_XSALORDER ADD (FPAYMODE VARCHAR(30) DEFAULT 'CREDIT' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FINPUTAMOUNT') 
 ALTER TABLE T_SM_XSALORDER ADD (FINPUTAMOUNT CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FCUSTOMERID') 
 ALTER TABLE T_SM_SALORDER ADD (FCUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FDELIVERYWAYID') 
 ALTER TABLE T_SM_SALORDER ADD (FDELIVERYWAYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FRECCUSTOMERID') 
 ALTER TABLE T_SM_SALORDER ADD (FRECCUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FSETTLECUSTOMERID') 
 ALTER TABLE T_SM_SALORDER ADD (FSETTLECUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FPAYINGCUSTOMERID') 
 ALTER TABLE T_SM_SALORDER ADD (FPAYINGCUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FLOCATION') 
 ALTER TABLE T_SM_SALORDER ADD (FLOCATION NVARCHAR(255) );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FRECEIVEADDRESS') 
 ALTER TABLE T_SM_SALORDER ADD (FRECEIVEADDRESS NVARCHAR(512) );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FRECLINKMANID') 
 ALTER TABLE T_SM_SALORDER ADD (FRECLINKMANID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FLINKMANID') 
 ALTER TABLE T_SM_SALORDER ADD (FLINKMANID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FADDRESS') 
 ALTER TABLE T_SM_SALORDER ADD (FADDRESS NVARCHAR(512) );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FCURRENCYID') 
 ALTER TABLE T_SM_SALORDER ADD (FCURRENCYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FSETTLECURRENCYID') 
 ALTER TABLE T_SM_SALORDER ADD (FSETTLECURRENCYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FSETTLETYPEID') 
 ALTER TABLE T_SM_SALORDER ADD (FSETTLETYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FSETTLEORGID') 
 ALTER TABLE T_SM_SALORDER ADD (FSETTLEORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FEXRATETABLEID') 
 ALTER TABLE T_SM_SALORDER ADD (FEXRATETABLEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FEXCHANGERATE') 
 ALTER TABLE T_SM_SALORDER ADD (FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FRECCONDITIONID') 
 ALTER TABLE T_SM_SALORDER ADD (FRECCONDITIONID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FTOTALTAXAMOUNT') 
 ALTER TABLE T_SM_SALORDER ADD (FTOTALTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FTOTALAMOUNT') 
 ALTER TABLE T_SM_SALORDER ADD (FTOTALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FTOTALALLAMOUNT') 
 ALTER TABLE T_SM_SALORDER ADD (FTOTALALLAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FISTAX') 
 ALTER TABLE T_SM_SALORDER ADD (FISTAX CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FCURTOTALAMOUNT') 
 ALTER TABLE T_SM_SALORDER ADD (FCURTOTALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FCURTOTALALLAMOUNT') 
 ALTER TABLE T_SM_SALORDER ADD (FCURTOTALALLAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FMARGINLEVEL') 
 ALTER TABLE T_SM_SALORDER ADD (FMARGINLEVEL DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FMARGIN') 
 ALTER TABLE T_SM_SALORDER ADD (FMARGIN DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FASSOCIATEMARGIN') 
 ALTER TABLE T_SM_SALORDER ADD (FASSOCIATEMARGIN DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FASSREFUNDMARGIN') 
 ALTER TABLE T_SM_SALORDER ADD (FASSREFUNDMARGIN DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FISPAYRATE') 
 ALTER TABLE T_SM_SALORDER ADD (FISPAYRATE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FEXRATEDATE') 
 ALTER TABLE T_SM_SALORDER ADD (FEXRATEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FRECEIPTAMOUNT') 
 ALTER TABLE T_SM_SALORDER ADD (FRECEIPTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FPRERECEIPTAMOUNT') 
 ALTER TABLE T_SM_SALORDER ADD (FPRERECEIPTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FPAYMODE') 
 ALTER TABLE T_SM_SALORDER ADD (FPAYMODE VARCHAR(30) DEFAULT 'CREDIT' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FINPUTAMOUNT') 
 ALTER TABLE T_SM_SALORDER ADD (FINPUTAMOUNT CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FDELIVERORGID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FDELIVERORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FDELIVERDEPTID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FDELIVERDEPTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FINVGROUPID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FINVGROUPID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FDELIVEROPERATORID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FDELIVEROPERATORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FCUSTOMERID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FCUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FDELIVERPATTERNID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FDELIVERPATTERNID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FRECCUSTOMERID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FRECCUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FSETTLECUSTOMERID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FSETTLECUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FPAYINGCUSTOMERID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FPAYINGCUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FRECEIVEADDRESS') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FRECEIVEADDRESS NVARCHAR(512) DEFAULT ' ' );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FRECLINKMANID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FRECLINKMANID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FLINKMANID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FLINKMANID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FADDRESS') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FADDRESS NVARCHAR(512) DEFAULT ' ' );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FCURRENCYID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FCURRENCYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FSETTLECURRENCYID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FSETTLECURRENCYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FSETTLETYPEID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FSETTLETYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FSETTLEORGID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FSETTLEORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FEXRATETABLEID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FEXRATETABLEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FRECCONDITIONID') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FRECCONDITIONID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FISTAX') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FISTAX CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FEXCHANGERATE') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FISPAYRATE') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FISPAYRATE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FEXRATEDATE') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FEXRATEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FPAYMODE') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FPAYMODE VARCHAR(30) DEFAULT 'CREDIT' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FENTRYSETTLEORGID') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FENTRYSETTLEORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FPRICEUNITID') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FPRICEUNITID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FPRICEQTY') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FPRICEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FPRICEUNITRATE') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FPRICEUNITRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FPRICE') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FTAXRATEID') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FTAXRATEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FTAXRATE') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FPRICEANDTAX') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FPRICEANDTAX DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FAMOUNT') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FTAXAMOUNT') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FDISCOUNTTYPE') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FDISCOUNTRATE') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FDISCOUNTRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FDISCOUNTAMOUNT') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FDISCOUNTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FAMOUNTANDTAX') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FAMOUNTANDTAX DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FCURAMOUNT') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FCURAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FCURAMOUNTANDTAX') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FCURAMOUNTANDTAX DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLYENTRY' AND KSQL_COL_NAME ='FCURTAXAMOUNT') 
 ALTER TABLE T_SM_RETURNAPPLYENTRY ADD (FCURTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY' AND KSQL_COL_NAME ='FENTRYSETTLEORGID') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY ADD (FENTRYSETTLEORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY' AND KSQL_COL_NAME ='FPRICE') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY ADD (FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY' AND KSQL_COL_NAME ='FPRICEANDTAX') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY ADD (FPRICEANDTAX DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY' AND KSQL_COL_NAME ='FTAXRATE') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY ADD (FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY' AND KSQL_COL_NAME ='FDISCOUNTTYPE') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY' AND KSQL_COL_NAME ='FTAXRATEID') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY ADD (FTAXRATEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY' AND KSQL_COL_NAME ='FCURTAXAMOUNT') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY ADD (FCURTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY' AND KSQL_COL_NAME ='FTAXAMOUNT') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY ADD (FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY' AND KSQL_COL_NAME ='FDISCOUNTRATE') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY ADD (FDISCOUNTRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY' AND KSQL_COL_NAME ='FDISCOUNTAMOUNT') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY ADD (FDISCOUNTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY' AND KSQL_COL_NAME ='FAMOUNT') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY ADD (FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY' AND KSQL_COL_NAME ='FAMOUNTANDTAX') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY ADD (FAMOUNTANDTAX DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY' AND KSQL_COL_NAME ='FCURAMOUNT') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY ADD (FCURAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY' AND KSQL_COL_NAME ='FCURAMOUNTANDTAX') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY ADD (FCURAMOUNTANDTAX DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FPRICE') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FTAXRATE') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FPRICEANDTAX') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FPRICEANDTAX DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FCURTAXAMOUNT') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FCURTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FTAXAMOUNT') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FDISCOUNTTYPE') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FDISCOUNTRATE') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FDISCOUNTRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FDISCOUNTAMOUNT') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FDISCOUNTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FAMOUNT') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FCURAMOUNT') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FCURAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FAMOUNTANDTAX') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FAMOUNTANDTAX DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FCURAMOUNTANDTAX') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FCURAMOUNTANDTAX DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FENTRYSETTLEORGID') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FENTRYSETTLEORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FSETTLEDEPTID') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FSETTLEDEPTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FSETTLEAMOUNT') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FSETTLEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FTAXRATEID') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FTAXRATEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FISCONTROLDAY') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FISCONTROLDAY CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FDELIVERADVDAYS') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FDELIVERADVDAYS INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY' AND KSQL_COL_NAME ='FDELIVERDELAYDAYS') 
 ALTER TABLE T_SM_XSALORDERENTRY ADD (FDELIVERDELAYDAYS INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FPRICE') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FTAXRATE') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FPRICEANDTAX') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FPRICEANDTAX DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FCURTAXAMOUNT') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FCURTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FTAXAMOUNT') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FDISCOUNTTYPE') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FDISCOUNTRATE') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FDISCOUNTRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FDISCOUNTAMOUNT') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FDISCOUNTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FAMOUNT') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FCURAMOUNT') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FCURAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FAMOUNTANDTAX') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FAMOUNTANDTAX DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FCURAMOUNTANDTAX') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FCURAMOUNTANDTAX DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FENTRYSETTLEORGID') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FENTRYSETTLEORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FSETTLEDEPTID') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FSETTLEDEPTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FSETTLEAMOUNT') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FSETTLEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FTAXRATEID') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FTAXRATEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FISCONTROLDAY') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FISCONTROLDAY CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FDELIVERADVDAYS') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FDELIVERADVDAYS INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY' AND KSQL_COL_NAME ='FDELIVERDELAYDAYS') 
 ALTER TABLE T_SM_SALORDERENTRY ADD (FDELIVERDELAYDAYS INT DEFAULT 0 NOT NULL );

/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\SM_table.sql **/
