/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\SBD_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_MATCHOUT_ORDER') 
 CREATE TABLE T_BD_MATCHOUT_ORDER (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSOURCE NVARCHAR(50) DEFAULT 'im_inv_realbalance' NOT NULL,
FSRCCOL NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSRCCOLNAME NVARCHAR(300) DEFAULT ' ' NOT NULL,
FTYPE NVARCHAR(50) DEFAULT 'asc' NOT NULL,
FCUSTOMORDER NVARCHAR(500) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_MATCHOUT_RULE') 
 CREATE TABLE T_BD_MATCHOUT_RULE (
FID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FENABLE VARCHAR(5) DEFAULT '1' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT 'A' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FISPRESET CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_MATCHOUT_RULE_L') 
 CREATE TABLE T_BD_MATCHOUT_RULE_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


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

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