/**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_STRUCTOFENT' AND KSQL_COL_NAME IN ('FOWNER')) 
 ALTER TABLE T_BCM_STRUCTOFENT ADD (FOWNER BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFENT' AND KSQL_COL_NAME IN ('FEXECUTOR')) 
 ALTER TABLE T_BCM_STRUCTOFENT ADD (FEXECUTOR BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CHECKTMPL' AND KSQL_COL_NAME IN ('FCHECKCONFIG')) 
 ALTER TABLE T_BCM_CHECKTMPL ADD (FCHECKCONFIG VARCHAR(30) DEFAULT ' ' NOT NULL );
 EXEC p_AlterColumn 'T_BCM_DISTRIBUTION', 'FTEXTNAME', 'NVARCHAR(100)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SRCDIMBASEDATA' AND KSQL_COL_NAME IN ('FADAPTER')) 
 ALTER TABLE T_BCM_SRCDIMBASEDATA ADD (FADAPTER INT DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_BCM_INTEGRATESCHEME', 'FADAPTER', 'INT', 'NOT NULL', '1111', '0';

 EXEC p_AlterColumn 'T_BCM_ENTITYNAMERECORD_L', 'FNAME', 'VARCHAR(255)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CANCELMERGE') 
 CREATE TABLE T_BCM_CANCELMERGE (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCENARIOID BIGINT DEFAULT 0 NOT NULL,
FYEARID BIGINT DEFAULT 0 NOT NULL,
FPERIODID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL
);


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

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


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