/**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_XSALORDER' AND KSQL_COL_NAME ='FCHANGECANCELSTATUS') 
 ALTER TABLE T_SM_XSALORDER ADD (FCHANGECANCELSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FCHANGECANCELER') 
 ALTER TABLE T_SM_XSALORDER ADD (FCHANGECANCELER BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FCHANGECANCELDATE') 
 ALTER TABLE T_SM_XSALORDER ADD (FCHANGECANCELDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY_R' AND KSQL_COL_NAME ='FSOURCEENTRYID') 
 ALTER TABLE T_SM_XSALORDERENTRY_R ADD (FSOURCEENTRYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY_R' AND KSQL_COL_NAME ='FMAINBILLENTITY') 
 ALTER TABLE T_SM_XSALORDERENTRY_R ADD (FMAINBILLENTITY VARCHAR(36) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY_R' AND KSQL_COL_NAME ='FMAINBILLID') 
 ALTER TABLE T_SM_XSALORDERENTRY_R ADD (FMAINBILLID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY_R' AND KSQL_COL_NAME ='FMAINBILLENTRYID') 
 ALTER TABLE T_SM_XSALORDERENTRY_R ADD (FMAINBILLENTRYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY_R' AND KSQL_COL_NAME ='FMAINBILLNUMBER') 
 ALTER TABLE T_SM_XSALORDERENTRY_R ADD (FMAINBILLNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY_R' AND KSQL_COL_NAME ='FMAINBILLENTRYSEQ') 
 ALTER TABLE T_SM_XSALORDERENTRY_R ADD (FMAINBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY_R' AND KSQL_COL_NAME ='FSRCBILLENTITY') 
 ALTER TABLE T_SM_XSALORDERENTRY_R ADD (FSRCBILLENTITY VARCHAR(36) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY_R' AND KSQL_COL_NAME ='FSRCBILLID') 
 ALTER TABLE T_SM_XSALORDERENTRY_R ADD (FSRCBILLID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY_R' AND KSQL_COL_NAME ='FSRCBILLNUMBER') 
 ALTER TABLE T_SM_XSALORDERENTRY_R ADD (FSRCBILLNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERENTRY_R' AND KSQL_COL_NAME ='FSRCBILLENTRYSEQ') 
 ALTER TABLE T_SM_XSALORDERENTRY_R ADD (FSRCBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL );

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