/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MDS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_WRTFF') 
 CREATE TABLE T_MDS_WRTFF (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FAUTOWROFF NVARCHAR(30) DEFAULT ' ' NOT NULL,
FWRITEOFFUC NVARCHAR(30) DEFAULT ' ' NOT NULL,
FWRITEOFFCOL BIGINT DEFAULT 0 NOT NULL,
FWFORDREGION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORDERDATE DATETIME,
FSENDDATE DATETIME,
FWFOFFORDERS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAHEADS BIGINT DEFAULT 0 NOT NULL,
FTAILS BIGINT DEFAULT 0 NOT NULL
);


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

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