/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BEI_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_TEMPLATE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_BEI_TEMPLATE ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_TEMPLATE' AND KSQL_COL_NAME ='FCOMMENT') 
 ALTER TABLE T_BEI_TEMPLATE ADD (FCOMMENT NVARCHAR(255) DEFAULT ' ' );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_TEMPLATEASSIGN' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_BEI_TEMPLATEASSIGN ADD (FNAME VARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_TEMPLATEASSIGN' AND KSQL_COL_NAME ='FCOMMENT') 
 ALTER TABLE T_BEI_TEMPLATEASSIGN ADD (FCOMMENT VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TMC_INIT' AND KSQL_COL_NAME ='FCOMMENT') 
 ALTER TABLE T_TMC_INIT ADD (FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TMC_INIT' AND KSQL_COL_NAME ='FLOCALEID') 
 ALTER TABLE T_TMC_INIT ADD (FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKLOG' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_BEI_BANKLOG ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKLOG' AND KSQL_COL_NAME ='FCOMMENT') 
 ALTER TABLE T_BEI_BANKLOG ADD (FCOMMENT NVARCHAR(255) DEFAULT ' ' );
 EXEC p_AlterColumn 'T_BEI_SERVICECONFIG', 'FNAME', 'NVARCHAR(100)', 'NOT NULL', '1111', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_SERVICECONFIG' AND KSQL_COL_NAME ='FCOMMENT') 
 ALTER TABLE T_BEI_SERVICECONFIG ADD (FCOMMENT NVARCHAR(255) DEFAULT ' ' );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKLOG_BAK' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_BEI_BANKLOG_BAK ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKLOG_BAK' AND KSQL_COL_NAME ='FCOMMENT') 
 ALTER TABLE T_BEI_BANKLOG_BAK ADD (FCOMMENT NVARCHAR(255) DEFAULT ' ' );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_PROXYBANK' AND KSQL_COL_NAME ='FCOMMENT') 
 ALTER TABLE T_BEI_PROXYBANK ADD (FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_PROXYBANK' AND KSQL_COL_NAME ='FLOCALEID') 
 ALTER TABLE T_BEI_PROXYBANK ADD (FLOCALEID VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_CROSSTRANFIELD' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_BEI_CROSSTRANFIELD ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_CROSSTRANFIELD' AND KSQL_COL_NAME ='FCOMMENT') 
 ALTER TABLE T_BEI_CROSSTRANFIELD ADD (FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_CROSSTRANFIELD' AND KSQL_COL_NAME ='FCOMBOXVALUE') 
 ALTER TABLE T_BEI_CROSSTRANFIELD ADD (FCOMBOXVALUE NVARCHAR(500) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_CROSSTRANTYPE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_BEI_CROSSTRANTYPE ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_CROSSTRANTYPE' AND KSQL_COL_NAME ='FCOMMENT') 
 ALTER TABLE T_BEI_CROSSTRANTYPE ADD (FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_TRANSTYPE' AND KSQL_COL_NAME ='FCOMMENT') 
 ALTER TABLE T_BEI_TRANSTYPE ADD (FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_TRANSTYPE' AND KSQL_COL_NAME ='FLOCALEID') 
 ALTER TABLE T_BEI_TRANSTYPE ADD (FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKAGENTPAYBILL' AND KSQL_COL_NAME ='FTEMPSTATUS') 
 ALTER TABLE T_BEI_BANKAGENTPAYBILL ADD (FTEMPSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL );
 --- drop column --------- 不允许删除表T_BEI_BANKAGENTPAYBILL的字段FISSINGLECA，请恢复pdm中的字段 ------------------- 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKTRANSDOWNBILL' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_BEI_BANKTRANSDOWNBILL ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKBALANCE' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_BEI_BANKBALANCE ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKTRANSUPBILL' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_BEI_BANKTRANSUPBILL ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_TRANSDETAIL' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_BEI_TRANSDETAIL ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_TRANSDETAIL' AND KSQL_COL_NAME ='FRULENAME') 
 ALTER TABLE T_BEI_TRANSDETAIL ADD (FRULENAME NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_UPDATEPAYSTAT' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_BEI_UPDATEPAYSTAT ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKPAYINGBILL_E' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_BEI_BANKPAYINGBILL_E ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKPAYINGBILL_E' AND KSQL_COL_NAME ='FTEMPSTATUS') 
 ALTER TABLE T_BEI_BANKPAYINGBILL_E ADD (FTEMPSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL );

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