/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\ER_table.sql **/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_HOTELCHECKINGBILL' AND KSQL_COL_NAME IN ('FCOMPANYID')) 
 ALTER TABLE T_ER_HOTELCHECKINGBILL ADD (FCOMPANYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PLANECHECKINGBILL' AND KSQL_COL_NAME IN ('FCOMPANYID')) 
 ALTER TABLE T_ER_PLANECHECKINGBILL ADD (FCOMPANYID BIGINT DEFAULT 0 NOT NULL );

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_HOTELCHECKINGBILL' AND KSQL_COL_NAME IN ('FORG')) 
 ALTER TABLE T_ER_HOTELCHECKINGBILL ADD (FORG BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PLANECHECKINGBILL' AND KSQL_COL_NAME IN ('FORG')) 
 ALTER TABLE T_ER_PLANECHECKINGBILL ADD (FORG BIGINT DEFAULT 0 NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_VEHICLECHECKINGBILL_A' AND KSQL_COL_NAME IN ('FORG')) 
 ALTER TABLE T_ER_VEHICLECHECKINGBILL_A ADD (FORG BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_INVOICESETTLE_REL' AND KSQL_COL_NAME IN ('FCOSTCOMPANYID')) 
 ALTER TABLE T_ER_INVOICESETTLE_REL ADD (FCOSTCOMPANYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_INVOICESETTLE_REL' AND KSQL_COL_NAME IN ('FDEPTID')) 
 ALTER TABLE T_ER_INVOICESETTLE_REL ADD (FDEPTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_INVOICESETTLE_REL' AND KSQL_COL_NAME IN ('FCOSTDEPTID')) 
 ALTER TABLE T_ER_INVOICESETTLE_REL ADD (FCOSTDEPTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_INVOICESETTLE_REL' AND KSQL_COL_NAME IN ('FCOMPANYID')) 
 ALTER TABLE T_ER_INVOICESETTLE_REL ADD (FCOMPANYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_ALLORDERBILL' AND KSQL_COL_NAME IN ('FDEPTID')) 
 ALTER TABLE T_ER_ALLORDERBILL ADD (FDEPTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_INVOICESETTLE_REL' AND KSQL_COL_NAME IN ('FALLORDERBASEID')) 
 ALTER TABLE T_ER_INVOICESETTLE_REL ADD (FALLORDERBASEID BIGINT DEFAULT 0 NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_ER_INVOICESETTLE_REL', 'FAIRPORTPRICE', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_ER_INVOICESETTLE_REL', 'FCOSTCOMPANYID', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_ER_INVOICESETTLE_REL', 'FDEPTID', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_ER_INVOICESETTLE_REL', 'FCOSTDEPTID', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_ER_INVOICESETTLE_REL', 'FCOMPANYID', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
--- EXEC p_AlterColumn 'T_ER_HOTELCHECKINGBILL', 'FORG', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 ---EXEC p_AlterColumn 'T_ER_PLANECHECKINGBILL', 'FORG', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 ---EXEC p_AlterColumn 'T_ER_VEHICLECHECKINGBILL_A', 'FORG', 'NULL', 'NULL', '1001', 'NULL';


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