/**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_ORGMAP_TAXORG_L') 
 CREATE TABLE T_TCTB_ORGMAP_TAXORG_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL
);


 EXEC p_AlterColumn 'T_TCTB_ORGMAPENTITY', 'FNAME', 'NVARCHAR(100)', 'NOT NULL', '1111', ''' ''';

 EXEC p_AlterColumn 'T_TCTB_ORGMAPENTITY_L', 'FNAME', 'NVARCHAR(100)', 'NOT NULL', '1111', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_ORGMAP_TAXORG' AND KSQL_COL_NAME ='FNUMBER') 
 ALTER TABLE T_TCTB_ORGMAP_TAXORG ADD (FNUMBER VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_ORGMAP_TAXORG' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_TCTB_ORGMAP_TAXORG ADD (FNAME VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_ORGMAP_TAXORG' AND KSQL_COL_NAME ='FSTATUS') 
 ALTER TABLE T_TCTB_ORGMAP_TAXORG ADD (FSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_ORGMAP_TAXORG' AND KSQL_COL_NAME ='FCREATORID') 
 ALTER TABLE T_TCTB_ORGMAP_TAXORG ADD (FCREATORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_ORGMAP_TAXORG' AND KSQL_COL_NAME ='FMODIFIERID') 
 ALTER TABLE T_TCTB_ORGMAP_TAXORG ADD (FMODIFIERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_ORGMAP_TAXORG' AND KSQL_COL_NAME ='FENABLE') 
 ALTER TABLE T_TCTB_ORGMAP_TAXORG ADD (FENABLE VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_ORGMAP_TAXORG' AND KSQL_COL_NAME ='FCREATETIME') 
 ALTER TABLE T_TCTB_ORGMAP_TAXORG ADD (FCREATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_ORGMAP_TAXORG' AND KSQL_COL_NAME ='FMODIFYTIME') 
 ALTER TABLE T_TCTB_ORGMAP_TAXORG ADD (FMODIFYTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_ORGMAP_TAXORG' AND KSQL_COL_NAME ='FMASTERID') 
 ALTER TABLE T_TCTB_ORGMAP_TAXORG ADD (FMASTERID BIGINT DEFAULT 0 NOT NULL );

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