IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDER' AND KSQL_COL_NAME ='FCONFIGUREDCODE') 
 ALTER TABLE T_MRP_XPLANORDER ADD (FCONFIGUREDCODE BIGINT DEFAULT 0 NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDER' AND KSQL_COL_NAME ='FBILLTYPEID') 
 ALTER TABLE T_MRP_XPLANORDER ADD (FBILLTYPEID BIGINT DEFAULT 0 NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDERENTRY' AND KSQL_COL_NAME ='FENTRYCONFIGUREDCODE') 
 ALTER TABLE T_MRP_XPLANORDERENTRY ADD (FENTRYCONFIGUREDCODE BIGINT DEFAULT 0 NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDERENTRY' AND KSQL_COL_NAME ='FENTRYDROPREQUIREQTY') 
 ALTER TABLE T_MRP_XPLANORDERENTRY ADD (FENTRYDROPREQUIREQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDER' AND KSQL_COL_NAME ='FPLANTAGS') 
 ALTER TABLE T_MRP_XPLANORDER ADD (FPLANTAGS BIGINT DEFAULT 0 NOT NULL );

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

 
  IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDER' AND KSQL_COL_NAME ='FISHISTORY') 
 ALTER TABLE T_MRP_XPLANORDER ADD (FISHISTORY CHAR(1) DEFAULT '0' NOT NULL );
  IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDER' AND KSQL_COL_NAME ='FHISTORYDATE') 
 ALTER TABLE T_MRP_XPLANORDER ADD (FHISTORYDATE DATETIME );
 
 -- 计划订单新增需求单据ID字段
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDER' AND KSQL_COL_NAME ='FDEMANDBILLID') 
 ALTER TABLE T_MRP_XPLANORDER ADD (FDEMANDBILLID NVARCHAR(50) DEFAULT ' ' NOT NULL );
 
 -- 计划订单新增需求单据编号字段
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDER' AND KSQL_COL_NAME ='FDEMANDBILL') 
 ALTER TABLE T_MRP_XPLANORDER ADD (FDEMANDBILL NVARCHAR(50) DEFAULT ' ' NOT NULL );
 
 -- 计划订单新增需求单据行号字段
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDER' AND KSQL_COL_NAME ='FDEMANDSEQ') 
 ALTER TABLE T_MRP_XPLANORDER ADD (FDEMANDSEQ INT DEFAULT 0 NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDER' AND KSQL_COL_NAME ='FENTRYSEQ') 
 ALTER TABLE T_MRP_XPLANORDER ADD (FENTRYSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL );
 
   IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDER' AND KSQL_COL_NAME ='FPLANNUM') 
 ALTER TABLE T_MRP_XPLANORDER ADD (FPLANNUM BIGINT DEFAULT 0 NOT NULL );
 
  IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDER' AND KSQL_COL_NAME ='FCHANGTRACKNUM') 
 ALTER TABLE T_MRP_XPLANORDER ADD (FCHANGTRACKNUM BIGINT DEFAULT 0 NOT NULL );
 
 -- 计划订单新增需求单据分录ID字段
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDER' AND KSQL_COL_NAME ='FDEMANDBILLENTRYID') 
 ALTER TABLE T_MRP_XPLANORDER ADD (FDEMANDBILLENTRYID NVARCHAR(50) DEFAULT ' ' NOT NULL );

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDERENTRY' AND KSQL_COL_NAME ='FENTRYREPLACEPLAN') 
 ALTER TABLE T_MRP_XPLANORDERENTRY ADD (FENTRYREPLACEPLAN BIGINT DEFAULT 0 NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDERENTRY' AND KSQL_COL_NAME ='FENTRYLEADTIME') 
 ALTER TABLE T_MRP_XPLANORDERENTRY ADD (FENTRYLEADTIME INT DEFAULT 0 NOT NULL);
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDERENTRY' AND KSQL_COL_NAME ='FWASTAGERATEFORMULA') 
 ALTER TABLE T_MRP_XPLANORDERENTRY ADD (FWASTAGERATEFORMULA  NVARCHAR(30) DEFAULT ' ' NOT NULL);

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

   IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_XPLANORDERLOGENTRY' AND KSQL_COL_NAME ='FCHANGTRACKNUM') 
 ALTER TABLE T_MRP_XPLANORDERLOGENTRY ADD (FCHANGTRACKNUM  NVARCHAR(100) DEFAULT ' ' NOT NULL  );


