/**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_DELIVERPATTERN' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_SM_DELIVERPATTERN ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_DELIVERNOTICE' AND KSQL_COL_NAME ='FCOMMENT') 
 ALTER TABLE T_SM_DELIVERNOTICE ADD (FCOMMENT NVARCHAR(512) );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FBILLCRETYPE') 
 ALTER TABLE T_SM_XSALORDER ADD (FBILLCRETYPE VARCHAR(5) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_XSALORDER' AND KSQL_COL_NAME ='FCOMMENT') 
 ALTER TABLE T_SM_XSALORDER ADD (FCOMMENT NVARCHAR(512) );
 EXEC p_AlterColumn 'T_SM_XSALORDER_L', 'FCOMMENT', 'NVARCHAR(512)', 'NULL', '0001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_RETURNAPPLY' AND KSQL_COL_NAME ='FCOMMENT') 
 ALTER TABLE T_SM_RETURNAPPLY ADD (FCOMMENT NVARCHAR(512) );
 EXEC p_AlterColumn 'T_SM_SALORDER_L', 'FCOMMENT', 'NVARCHAR(512)', 'NULL', '0001', 'NULL';

 EXEC p_AlterColumn 'T_SM_DELIVERNOTICE_L', 'FCOMMENT', 'NVARCHAR(512)', 'NULL', '0001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FBILLCRETYPE') 
 ALTER TABLE T_SM_SALORDER ADD (FBILLCRETYPE VARCHAR(5) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SALORDER' AND KSQL_COL_NAME ='FCOMMENT') 
 ALTER TABLE T_SM_SALORDER ADD (FCOMMENT NVARCHAR(512) );

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