IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_FLEXMETRICDEFINE') 
 CREATE TABLE T_MSPLAN_FLEXMETRICDEFINE (
	FID BIGINT DEFAULT 0 NOT NULL,
	FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
	FSOURCEENTITYID NVARCHAR(30) DEFAULT ' ' NOT NULL,
	FTARGETENTITYLD NVARCHAR(36) DEFAULT ' ' NOT NULL,
	FISSYS CHAR(1) DEFAULT '0' NOT NULL,
	FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
	FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
	FCREATORID BIGINT DEFAULT 0 NOT NULL,
	FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
	FENABLE NVARCHAR(50) DEFAULT ' ' NOT NULL,
	FCREATETIME DATETIME,
	FMODIFYTIME DATETIME,
	FMASTERID BIGINT DEFAULT 0 NOT NULL
);

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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_FLEXVALS')
 CREATE TABLE T_MSPLAN_FLEXVALS (
	FID BIGINT DEFAULT 0 NOT NULL,
	FENTRYID BIGINT DEFAULT 0 NOT NULL,
	FSEQ INT DEFAULT 0 NOT NULL,
	FSOURCEBDID BIGINT DEFAULT 0 NOT NULL
 );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_REPLACESETTING')
 CREATE TABLE T_MSPLAN_REPLACESETTING (
	FENTRYID BIGINT DEFAULT 0 NOT NULL,
	FDETAILID BIGINT DEFAULT 0 NOT NULL,
	FSEQ INT DEFAULT 0 NOT NULL,
	FTARGETBDID BIGINT DEFAULT 0 NOT NULL,
	FPRIORITY BIGINT DEFAULT 0 NOT NULL
 );