/**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_SALORDERRPENTRY' AND KSQL_COL_NAME ='FRECSETTLEORGID') 
 ALTER TABLE T_SM_SALORDERRPENTRY ADD (FRECSETTLEORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDERRPENTRY' AND KSQL_COL_NAME ='FRECSETTLEORGID') 
 ALTER TABLE T_SM_XSALORDERRPENTRY ADD (FRECSETTLEORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY_R' AND KSQL_COL_NAME ='FSRCBILLENTITY') 
 ALTER TABLE T_SM_SALORDERENTRY_R ADD (FSRCBILLENTITY NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY_R' AND KSQL_COL_NAME ='FSRCBILLID') 
 ALTER TABLE T_SM_SALORDERENTRY_R ADD (FSRCBILLID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY_R' AND KSQL_COL_NAME ='FSRCBILLENTRYID') 
 ALTER TABLE T_SM_SALORDERENTRY_R ADD (FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY_R' AND KSQL_COL_NAME ='FSRCBILLNUMBER') 
 ALTER TABLE T_SM_SALORDERENTRY_R ADD (FSRCBILLNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY_R' AND KSQL_COL_NAME ='FSRCBILLENTRYSEQ') 
 ALTER TABLE T_SM_SALORDERENTRY_R ADD (FSRCBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY_R' AND KSQL_COL_NAME ='FMAINBILLENTITY') 
 ALTER TABLE T_SM_SALORDERENTRY_R ADD (FMAINBILLENTITY VARCHAR(36) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY_R' AND KSQL_COL_NAME ='FMAINBILLID') 
 ALTER TABLE T_SM_SALORDERENTRY_R ADD (FMAINBILLID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY_R' AND KSQL_COL_NAME ='FMAINBILLENTRYID') 
 ALTER TABLE T_SM_SALORDERENTRY_R ADD (FMAINBILLENTRYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY_R' AND KSQL_COL_NAME ='FMAINBILLNUMBER') 
 ALTER TABLE T_SM_SALORDERENTRY_R ADD (FMAINBILLNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDERENTRY_R' AND KSQL_COL_NAME ='FMAINBILLENTRYSEQ') 
 ALTER TABLE T_SM_SALORDERENTRY_R ADD (FMAINBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY_R' AND KSQL_COL_NAME ='FASSOCIATEDBASEQTY') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY_R ADD (FASSOCIATEDBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY_R' AND KSQL_COL_NAME ='FASSOCIATEDQTY') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY_R ADD (FASSOCIATEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY_R' AND KSQL_COL_NAME ='FSRCBILLENTITY') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY_R ADD (FSRCBILLENTITY NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY_R' AND KSQL_COL_NAME ='FSRCBILLID') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY_R ADD (FSRCBILLID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY_R' AND KSQL_COL_NAME ='FSRCBILLENTRYID') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY_R ADD (FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY_R' AND KSQL_COL_NAME ='FSRCBILLNUMBER') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY_R ADD (FSRCBILLNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY_R' AND KSQL_COL_NAME ='FSRCBILLENTRYSEQ') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY_R ADD (FSRCBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY_R' AND KSQL_COL_NAME ='FMAINBILLENTITY') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY_R ADD (FMAINBILLENTITY VARCHAR(36) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY_R' AND KSQL_COL_NAME ='FMAINBILLID') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY_R ADD (FMAINBILLID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY_R' AND KSQL_COL_NAME ='FMAINBILLENTRYID') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY_R ADD (FMAINBILLENTRYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY_R' AND KSQL_COL_NAME ='FMAINBILLNUMBER') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY_R ADD (FMAINBILLNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICEENTRY_R' AND KSQL_COL_NAME ='FMAINBILLENTRYSEQ') 
 ALTER TABLE T_SM_DELIVERNOTICEENTRY_R ADD (FMAINBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL );

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