/**Begin D:\PDM_UPGRADE\PDM_UPGRADE_1.1\PDM_UPGRADE\PDM1\BCM_table.sql **/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_TMPLCOLDIM_L' AND KSQL_COL_NAME ='FHEADER') 
 ALTER TABLE T_BCM_TMPLCOLDIM_L ADD (FHEADER NVARCHAR(50) DEFAULT ' ' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_RULEVERSCATALOG') 
 CREATE TABLE T_BCM_RULEVERSCATALOG (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFDATASORT' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_BCM_STRUCTOFDATASORT ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFDATASORT' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_BCM_STRUCTOFDATASORT ADD (FNAME NVARCHAR(200) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFDATASORT' AND KSQL_COL_NAME ='FSIMPLENAME') 
 ALTER TABLE T_BCM_STRUCTOFDATASORT ADD (FSIMPLENAME NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_TMPLCOLDIM' AND KSQL_COL_NAME ='FHEADER') 
 ALTER TABLE T_BCM_TMPLCOLDIM ADD (FHEADER VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_MEMBOFDATASORT' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_BCM_MEMBOFDATASORT ADD (FNAME NVARCHAR(200) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_MEMBOFDATASORT' AND KSQL_COL_NAME ='FSIMPLENAME') 
 ALTER TABLE T_BCM_MEMBOFDATASORT ADD (FSIMPLENAME NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CSLSCHEME' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_BCM_CSLSCHEME ADD (FNAME NVARCHAR(500) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CSLSCHEME' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_BCM_CSLSCHEME ADD (FDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL );
 EXEC p_AlterColumn 'T_BCM_INVELIMTEMPLATE', 'FNAME', 'NVARCHAR(100)', 'NOT NULL', '1111', ''' ''';

 EXEC p_AlterColumn 'T_BCM_INVELIMTEMPLATE', 'FREMARK', 'NVARCHAR(200)', 'NOT NULL', '1111', ''' ''';

 EXEC p_AlterColumn 'T_BCM_TEMPLATE', 'FVERSIONDESCRIPTION', 'NVARCHAR(500)', 'NOT NULL', '1111', ''' ''';




/**End D:\PDM_UPGRADE\PDM_UPGRADE_1.1\PDM_UPGRADE\PDM1\BCM_table.sql **/
