/**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_CHKNOTEINFO' AND KSQL_COL_NAME IN ('FDIMSTR')) 
 ALTER TABLE T_BCM_CHKNOTEINFO ADD (FDIMSTR VARCHAR(255) DEFAULT ' ' NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 /**EXEC p_AlterColumn 'T_BCM_CHKNOTEINFO', '维度组合', 'NULL', 'NULL', '1001', 'NULL';**/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DIMMEMBCOMBENTRY' AND KSQL_COL_NAME IN ('FPLUSMINUS')) 
 ALTER TABLE T_BCM_DIMMEMBCOMBENTRY ADD (FPLUSMINUS CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_MODEL' AND KSQL_COL_NAME IN ('FISSPPTDATASORT')) 
 ALTER TABLE T_BCM_MODEL ADD (FISSPPTDATASORT CHAR(1) DEFAULT '0' NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_TEMPLATE', 'FEXCELDATA', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUSTDATA' AND KSQL_COL_NAME IN ('FDATASORTID')) 
 ALTER TABLE T_BCM_RPTADJUSTDATA ADD (FDATASORTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CHKREPORT' AND KSQL_COL_NAME IN ('FNOTE')) 
 ALTER TABLE T_BCM_CHKREPORT ADD (FNOTE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CHKREPORT' AND KSQL_COL_NAME IN ('FFULLLFORMULA')) 
 ALTER TABLE T_BCM_CHKREPORT ADD (FFULLLFORMULA VARCHAR(2000) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CHKREPORT' AND KSQL_COL_NAME IN ('FFULLRFORMULA')) 
 ALTER TABLE T_BCM_CHKREPORT ADD (FFULLRFORMULA VARCHAR(2000) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_SCHEMEEXECUTEREC') 
 CREATE TABLE T_BCM_SCHEMEEXECUTEREC (
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,
FASSIGNCOUNT INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SRCDIMMEMBENTRY' AND KSQL_COL_NAME IN ('FTAGDIMMEMBID')) 
 ALTER TABLE T_BCM_SRCDIMMEMBENTRY ADD (FTAGDIMMEMBID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SRCDIMMEMBENTRY' AND KSQL_COL_NAME IN ('FTAGDIMMEMBNUMBER')) 
 ALTER TABLE T_BCM_SRCDIMMEMBENTRY ADD (FTAGDIMMEMBNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SRCDIMMEMBENTRY' AND KSQL_COL_NAME IN ('FRELATION')) 
 ALTER TABLE T_BCM_SRCDIMMEMBENTRY ADD (FRELATION CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CHKATTDETAIL') 
 CREATE TABLE T_BCM_CHKATTDETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FSUBFOLDER VARCHAR(256) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FATTTYPE CHAR(1) DEFAULT '1' NOT NULL,
FREPORTID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSIZE DECIMAL(10,3) DEFAULT 0 NOT NULL,
FUID NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FMODIFYDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CHKNOTEDETAIL') 
 CREATE TABLE T_BCM_CHKNOTEDETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FNAME VARCHAR(255) DEFAULT ' ' NOT NULL,
FDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL,
FTYPE CHAR(1) DEFAULT '1' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFCURRENCY' AND KSQL_COL_NAME IN ('FSCALE')) 
 ALTER TABLE T_BCM_STRUCTOFCURRENCY ADD (FSCALE INT DEFAULT 2 NOT NULL );
 --- drop TABLE --------- 请认真检查该脚本 ------------------- 
IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CHKATTACHMENT') 
 DROP TABLE T_BCM_CHKATTACHMENT;

 --- drop TABLE --------- 请认真检查该脚本 ------------------- 
IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CHKNOTE') 
 DROP TABLE T_BCM_CHKNOTE;


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