/**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_DIMENSION' AND KSQL_COL_NAME IN ('FREFERID')) 
 ALTER TABLE T_BCM_DIMENSION ADD (FREFERID BIGINT DEFAULT 0 NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DIMMAPINGENTRY' AND KSQL_COL_NAME IN ('FSRCTOCOMBINE')) 
 ALTER TABLE T_BCM_DIMMAPINGENTRY ADD (FSRCTOCOMBINE VARCHAR(50) DEFAULT ' ' NOT NULL );

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DIMMAPINGENTRY' AND KSQL_COL_NAME IN ('FTAGTOCOMBINE')) 
 ALTER TABLE T_BCM_DIMMAPINGENTRY ADD (FTAGTOCOMBINE VARCHAR(50) DEFAULT ' ' NOT NULL );
 
 
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_SCHEMECOLLECTLOG') 
 CREATE TABLE T_BCM_SCHEMECOLLECTLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCOLLECTSTATUS CHAR(1) DEFAULT '1' NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYDATE DATETIME,
FSCENARIOID BIGINT DEFAULT 0 NOT NULL,
FYEARID BIGINT DEFAULT 0 NOT NULL,
FPERIODID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL
);

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SCHEMEEXECUTEREC' AND KSQL_COL_NAME IN ('FSCENARIOID')) 
 ALTER TABLE T_BCM_SCHEMEEXECUTEREC ADD (FSCENARIOID BIGINT DEFAULT 0 NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SCHEMEEXECUTEREC' AND KSQL_COL_NAME IN ('FPERIODID')) 
 ALTER TABLE T_BCM_SCHEMEEXECUTEREC ADD (FPERIODID BIGINT DEFAULT 0 NOT NULL );
 
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SCHEMEEXECUTEREC' AND KSQL_COL_NAME IN ('FYEARID')) 
 ALTER TABLE T_BCM_SCHEMEEXECUTEREC ADD (FYEARID BIGINT DEFAULT 0 NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SCHEMEEXECUTEREC' AND KSQL_COL_NAME IN ('FCURRENCYID')) 
 ALTER TABLE T_BCM_SCHEMEEXECUTEREC ADD (FCURRENCYID BIGINT DEFAULT 0 NOT NULL );
 

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SRCDIMBASEDATA' AND KSQL_COL_NAME IN ('FTRACENUMBER')) 
 ALTER TABLE T_BCM_SRCDIMBASEDATA ADD (FTRACENUMBER BIGINT DEFAULT 0 NOT NULL );
 
 --- drop column --------- 请认真检查该脚本 ------------------- 
  EXEC p_AlterColumn 'T_BCM_SCHEMEEXECUTEREC', 'FASSIGNCOUNT', 'NULL', 'NULL', '1001', 'NULL';

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