/*主表添加通用字段*/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_AMOUNTFREED' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_ER_AMOUNTFREED ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_BIZ_INFO' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_ER_BIZ_INFO ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_HOTELCHECKINGBILL' AND KSQL_COL_NAME ='FBALANCEREMARK') 
 ALTER TABLE T_ER_HOTELCHECKINGBILL ADD (FBALANCEREMARK NVARCHAR(1000) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_INVOICESETTING' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_ER_INVOICESETTING ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PAYEE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_ER_PAYEE ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PLANECHECKINGBILL' AND KSQL_COL_NAME ='FBALANCEREMARK') 
 ALTER TABLE T_ER_PLANECHECKINGBILL ADD (FBALANCEREMARK NVARCHAR(1000) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMBILL' AND KSQL_COL_NAME ='FAPPLIERPOSITIONSTR') 
 ALTER TABLE T_ER_PUBREIMBILL ADD (FAPPLIERPOSITIONSTR VARCHAR(100) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REIMBURSEBILL' AND KSQL_COL_NAME ='FAPPLIERPOSITION') 
 ALTER TABLE T_ER_REIMBURSEBILL ADD (FAPPLIERPOSITION VARCHAR(100) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REPAYMENTBILL' AND KSQL_COL_NAME ='FAPPLIERPOSITIONSTR') 
 ALTER TABLE T_ER_REPAYMENTBILL ADD (FAPPLIERPOSITIONSTR VARCHAR(100) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REQBILL' AND KSQL_COL_NAME ='FAPPLIERPOSITION') 
 ALTER TABLE T_ER_REQBILL ADD (FAPPLIERPOSITION VARCHAR(100) DEFAULT ' ' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REIMBURSESTD' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_ER_REIMBURSESTD ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_TRAINCHECKINGBILL' AND KSQL_COL_NAME ='FBALANCEREMARK') 
 ALTER TABLE T_ER_TRAINCHECKINGBILL ADD (FBALANCEREMARK NVARCHAR(1000) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_VEHICLECHECKINGBILL' AND KSQL_COL_NAME ='FBALANCEREMARK') 
 ALTER TABLE T_ER_VEHICLECHECKINGBILL ADD (FBALANCEREMARK NVARCHAR(1000) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_TRIPAREA' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_ER_TRIPAREA ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_TRIPAREAGROUP' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_ER_TRIPAREAGROUP ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_TRIPAREAGROUP' AND KSQL_COL_NAME ='FFULLNAME') 
 ALTER TABLE T_ER_TRIPAREAGROUP ADD (FFULLNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_TRIPCONTROL' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_ER_TRIPCONTROL ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_TRIPEXPENSEITEM' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_ER_TRIPEXPENSEITEM ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_TRIPSTAND_ACCMOD' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_ER_TRIPSTAND_ACCMOD ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_TRIPSTANDARDTYPE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_ER_TRIPSTANDARDTYPE ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_TRIPSTDVEHICLE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_ER_TRIPSTDVEHICLE ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYLOANBILL' AND KSQL_COL_NAME ='FAPPLIERPOSITIONSTR') 
 ALTER TABLE T_ER_DAILYLOANBILL ADD (FAPPLIERPOSITIONSTR VARCHAR(100) DEFAULT ' ' NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL' AND KSQL_COL_NAME ='FAPPLIERPOSITIONSTR') 
 ALTER TABLE T_ER_DAILYREIMBURSEBILL ADD (FAPPLIERPOSITIONSTR VARCHAR(100) DEFAULT ' ' NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYBILL' AND KSQL_COL_NAME ='FAPPLIERPOSITIONSTR') 
 ALTER TABLE T_ER_DAILYAPPLYBILL ADD (FAPPLIERPOSITIONSTR VARCHAR(100) DEFAULT ' ' NOT NULL );
 
 
 /*修改字段的数据类型*/
EXEC p_AlterColumn 'T_ER_TRIPTYPE', 'FNAME', 'NVARCHAR(100)', 'NOT NULL', '1111', ''' ''';
EXEC p_AlterColumn 'T_ER_INTEGRALRECORD', 'FNAME', 'NVARCHAR(100)', 'NOT NULL', '1111', ''' ''';