/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\TCTB_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCTB_BUSINESS_DIMENSION') 
 CREATE TABLE T_TCTB_BUSINESS_DIMENSION (
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_USERTABLES WHERE KSQL_TABNAME = 'T_TCTB_TAXES_ENTRY') 
 CREATE TABLE T_TCTB_TAXES_ENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBIZDIMENSIONTYPE NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBIZDIMENSIONNAME NVARCHAR(200) DEFAULT ' ' NOT NULL,
FBIZDIMENSIONID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTAXITEM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FJTSJ DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_ORGMAP_BUSOBJECT' AND KSQL_COL_NAME ='FISDEFAULT') 
 ALTER TABLE T_TCTB_ORGMAP_BUSOBJECT ADD (FISDEFAULT CHAR(1) DEFAULT '0' NOT NULL );

 EXEC p_AlterColumn 'T_ITP_PROVISTON_TAXES', 'FENTITYNUMBER', 'VARCHAR(200)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ITP_PROVISTON_PLAN' AND KSQL_COL_NAME ='FISDIMPROVISION') 
 ALTER TABLE T_ITP_PROVISTON_PLAN ADD (FISDIMPROVISION CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ITP_PROVISTON_PLAN' AND KSQL_COL_NAME ='FPROVISIONDIMENSION') 
 ALTER TABLE T_ITP_PROVISTON_PLAN ADD (FPROVISIONDIMENSION VARCHAR(50) DEFAULT ' ' NOT NULL );
 
/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\TCTB_table.sql **/
