/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\CAS_table.sql **/
 EXEC p_AlterColumn 'T_BE_SCHEDULEJOB', 'FNAME', 'NVARCHAR(100)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_CAS_PAYMENTBILLENTRY', 'FCOREBILLNO', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_TEMPLATE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_CAS_TEMPLATE ADD (FNAME VARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_ACCOUNTASSIGN' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_CAS_ACCOUNTASSIGN ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_ACCOUNTASSIGN' AND KSQL_COL_NAME ='FUSAGECOMPANYNAME') 
 ALTER TABLE T_CAS_ACCOUNTASSIGN ADD (FUSAGECOMPANYNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_ACCOUNTBANKS' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_CAS_ACCOUNTBANKS ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_ACCOUNTBANKS' AND KSQL_COL_NAME ='FREMARK') 
 ALTER TABLE T_CAS_ACCOUNTBANKS ADD (FREMARK NVARCHAR(255) );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_JOURNALBALANCE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_CAS_JOURNALBALANCE ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_JOURNALBALANCE' AND KSQL_COL_NAME ='FREMARK') 
 ALTER TABLE T_CAS_JOURNALBALANCE ADD (FREMARK NVARCHAR(255) );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_RECEIVINGBILLTYPE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_CAS_RECEIVINGBILLTYPE ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYMENTBILLTYPE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_CAS_PAYMENTBILLTYPE ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_ACCOUNTPROPERTY' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_CAS_ACCOUNTPROPERTY ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_WBCONFIG' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_CAS_WBCONFIG ADD (FNAME VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_INTERPAYPLAN' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_CAS_INTERPAYPLAN ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_ACCOUNTCASHS' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_CAS_ACCOUNTCASHS ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
 EXEC p_AlterColumn 'T_CAS_FUNDFLOWITEM', 'FFULLNAME', 'NVARCHAR(256)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_FUNDFLOWITEM' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_CAS_FUNDFLOWITEM ADD (FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_RECPAYRULE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_CAS_RECPAYRULE ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );

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