/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\FA_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_INVENTSCHEME' AND KSQL_COL_NAME IN ('FNUMBER')) 
 ALTER TABLE T_FA_INVENTSCHEME ADD (FNUMBER NVARCHAR(60) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_INVENTSCHEME' AND KSQL_COL_NAME IN ('FSTATUS')) 
 ALTER TABLE T_FA_INVENTSCHEME ADD (FSTATUS CHAR(1) DEFAULT 'A' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_INVENTSCHEME' AND KSQL_COL_NAME IN ('FENABLE')) 
 ALTER TABLE T_FA_INVENTSCHEME ADD (FENABLE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_INVENTSCHEME' AND KSQL_COL_NAME IN ('FMASTERID')) 
 ALTER TABLE T_FA_INVENTSCHEME ADD (FMASTERID BIGINT DEFAULT 0 NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_FA_INVENTSCHEME', 'FBILLNO', 'NULL', 'NULL', '1001', 'NULL';

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

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

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

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

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

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

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

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

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

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

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

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

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

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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_INVENTORY_RECORD') 
 CREATE TABLE T_FA_INVENTORY_RECORD (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(60) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) DEFAULT 'C' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBARCODE NVARCHAR(60) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FMODEL NVARCHAR(60) DEFAULT ' ' NOT NULL,
FDIFFERENCE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVENTORYSTATE CHAR(1) DEFAULT 'B' NOT NULL,
FINVENTORYWAY CHAR(1) DEFAULT ' ' NOT NULL,
FREASON NVARCHAR(100) DEFAULT ' ' NOT NULL,
FINVENTORYUSER BIGINT DEFAULT 0 NOT NULL,
FINVENTORYTIME DATETIME,
FINVENTSCHEMEENTRYID BIGINT DEFAULT 0 NOT NULL,
FINVENTORYTASKID BIGINT DEFAULT 0 NOT NULL,
FINVENTORYQUANTITY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBOOKQUANTITY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCREATETIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_INVENTSCHEMEENTRY_L') 
 CREATE TABLE T_FA_INVENTSCHEMEENTRY_L (
FPKID NVARCHAR(18) DEFAULT ' ' NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_INVENTSCHEMEENTRY' AND KSQL_COL_NAME IN ('FNUMBER')) 
 ALTER TABLE T_FA_INVENTSCHEMEENTRY ADD (FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_INVENTSCHEMEENTRY' AND KSQL_COL_NAME IN ('FSTATUS')) 
 ALTER TABLE T_FA_INVENTSCHEMEENTRY ADD (FSTATUS CHAR(1) DEFAULT 'A' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_INVENTSCHEMEENTRY' AND KSQL_COL_NAME IN ('FCREATORID')) 
 ALTER TABLE T_FA_INVENTSCHEMEENTRY ADD (FCREATORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_INVENTSCHEMEENTRY' AND KSQL_COL_NAME IN ('FMODIFIERID')) 
 ALTER TABLE T_FA_INVENTSCHEMEENTRY ADD (FMODIFIERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_INVENTSCHEMEENTRY' AND KSQL_COL_NAME IN ('FENABLE')) 
 ALTER TABLE T_FA_INVENTSCHEMEENTRY ADD (FENABLE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_INVENTSCHEMEENTRY' AND KSQL_COL_NAME IN ('FCREATETIME')) 
 ALTER TABLE T_FA_INVENTSCHEMEENTRY ADD (FCREATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_INVENTSCHEMEENTRY' AND KSQL_COL_NAME IN ('FMODIFYTIME')) 
 ALTER TABLE T_FA_INVENTSCHEMEENTRY ADD (FMODIFYTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_INVENTSCHEMEENTRY' AND KSQL_COL_NAME IN ('FINVENTSCHEMEENTRYID')) 
 ALTER TABLE T_FA_INVENTSCHEMEENTRY ADD (FINVENTSCHEMEENTRYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_INVENTSCHEMEENTRY' AND KSQL_COL_NAME IN ('FASSETUNITID')) 
 ALTER TABLE T_FA_INVENTSCHEMEENTRY ADD (FASSETUNITID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_INVENTSCHEMEENTRY' AND KSQL_COL_NAME IN ('FMASTERID')) 
 ALTER TABLE T_FA_INVENTSCHEMEENTRY ADD (FMASTERID BIGINT DEFAULT 0 NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_FA_INVENTSCHEMEENTRY', 'FACCOUNTINGID', 'NULL', 'NULL', '1001', 'NULL';


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