/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest(平台_业务)\pdm\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SPCONFIG' AND KSQL_COL_NAME IN ('FID')) 
 ALTER TABLE T_BCM_SPCONFIG ADD (FID BIGINT DEFAULT 0 NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_SPCONFIG', 'ID', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFENT' AND KSQL_COL_NAME IN ('FREFERID')) 
 ALTER TABLE T_BCM_STRUCTOFENT ADD (FREFERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFFY' AND KSQL_COL_NAME IN ('FREFERID')) 
 ALTER TABLE T_BCM_STRUCTOFFY ADD (FREFERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFAUDITTRIAL' AND KSQL_COL_NAME IN ('FREFERID')) 
 ALTER TABLE T_BCM_STRUCTOFAUDITTRIAL ADD (FREFERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFPERIOD' AND KSQL_COL_NAME IN ('FREFERID')) 
 ALTER TABLE T_BCM_STRUCTOFPERIOD ADD (FREFERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFDEFINED' AND KSQL_COL_NAME IN ('FREFERID')) 
 ALTER TABLE T_BCM_STRUCTOFDEFINED ADD (FREFERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFPROCESS' AND KSQL_COL_NAME IN ('FREFERID')) 
 ALTER TABLE T_BCM_STRUCTOFPROCESS ADD (FREFERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFPROJECT' AND KSQL_COL_NAME IN ('FREFERID')) 
 ALTER TABLE T_BCM_STRUCTOFPROJECT ADD (FREFERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFCHANGETYPE' AND KSQL_COL_NAME IN ('FREFERID')) 
 ALTER TABLE T_BCM_STRUCTOFCHANGETYPE ADD (FREFERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFSCENE' AND KSQL_COL_NAME IN ('FREFERID')) 
 ALTER TABLE T_BCM_STRUCTOFSCENE ADD (FREFERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFRULE' AND KSQL_COL_NAME IN ('FREFERID')) 
 ALTER TABLE T_BCM_STRUCTOFRULE ADD (FREFERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFICENTITY' AND KSQL_COL_NAME IN ('FREFERID')) 
 ALTER TABLE T_BCM_STRUCTOFICENTITY ADD (FREFERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFVERSION' AND KSQL_COL_NAME IN ('FREFERID')) 
 ALTER TABLE T_BCM_STRUCTOFVERSION ADD (FREFERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DIMMEMBENTRY' AND KSQL_COL_NAME IN ('FPERIODNUMBER')) 
 ALTER TABLE T_BCM_DIMMEMBENTRY ADD (FPERIODNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DIMMEMBENTRY' AND KSQL_COL_NAME IN ('FPERIODID')) 
 ALTER TABLE T_BCM_DIMMEMBENTRY ADD (FPERIODID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFACCOUNTP' AND KSQL_COL_NAME IN ('FREFERID')) 
 ALTER TABLE T_BCM_STRUCTOFACCOUNTP ADD (FREFERID BIGINT DEFAULT 0 NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_SRCDIMMEMBENTRY', 'FPERIODNUMBER', 'NULL', 'NULL', '1001', 'NULL';

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

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

/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest(平台_业务)\pdm\BCM_table.sql **/
