/**Begin D:\PDM_UPGRADE\PDM1\EB_table.sql **/

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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_TEMPLATE' AND KSQL_COL_NAME IN ('FDATAUNIT')) 
 ALTER TABLE T_EB_TEMPLATE ADD (FDATAUNIT NVARCHAR(2) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_PJOTEMPLATE' AND KSQL_COL_NAME IN ('FSTATUS')) 
 ALTER TABLE T_EB_PJOTEMPLATE ADD (FSTATUS CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_PJOTEMPLATE' AND KSQL_COL_NAME IN ('FDEFINDIMENSION')) 
 ALTER TABLE T_EB_PJOTEMPLATE ADD (FDEFINDIMENSION NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_EXAMINECATEGORY') 
 CREATE TABLE T_EB_EXAMINECATEGORY (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPARENTID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FLEVEL INT DEFAULT 0 NOT NULL,
FISLEAF CHAR(1) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


 EXEC p_AlterColumn 'T_BGM_PRODETAIL', 'FSEQ', 'BIGINT', 'NOT NULL', '1111', '0';

 EXEC p_AlterColumn 'T_BGM_PRODETAIL', 'FPRODESCRIBE', 'NVARCHAR(255)', 'NOT NULL', '0011', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIM1')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIM1 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIM2')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIM2 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIM3')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIM3 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIM4')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIM4 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIM5')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIM5 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIM6')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIM6 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIM7')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIM7 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIM8')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIM8 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIM9')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIM9 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIM10')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIM10 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIM11')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIM11 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIM12')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIM12 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIM13')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIM13 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIM14')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIM14 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIM15')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIM15 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIMID1')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIMID1 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIMID2')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIMID2 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIMID3')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIMID3 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIMID4')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIMID4 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIMID5')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIMID5 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIMID6')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIMID6 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIMID7')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIMID7 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIMID8')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIMID8 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIMID9')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIMID9 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIMID10')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIMID10 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIMID11')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIMID11 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIMID12')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIMID12 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIMID13')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIMID13 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIMID14')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIMID14 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FDIMID15')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FDIMID15 NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME IN ('FPROAMOUNT')) 
 ALTER TABLE T_BGM_PRODETAIL ADD (FPROAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BGM_PRODETAIL', 'FSUBJECT', 'NULL', 'NULL', '1001', 'NULL';

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PROJECTAPPLY' AND KSQL_COL_NAME IN ('FMETABLE')) 
 ALTER TABLE T_BGM_PROJECTAPPLY ADD (FMETABLE NVARCHAR(2) DEFAULT ' ' NOT NULL );

/**End D:\PDM_UPGRADE\PDM1\EB_table.sql **/
