/**发票供应商建表语句 **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_INVOICECLOUDPROVIDER') 
 CREATE TABLE T_ER_INVOICECLOUDPROVIDER (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT 'C' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_INVOICECLOUDPROVIDER_L') 
 CREATE TABLE T_ER_INVOICECLOUDPROVIDER_L (
FPKID NVARCHAR(18) 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_USERTABLES WHERE KSQL_TABNAME = 'T_ER_INVOICESERVICEENTRY') 
 CREATE TABLE T_ER_INVOICESERVICEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSERVICENAME VARCHAR(255) DEFAULT ' ' NOT NULL,
FSERVICECLASS VARCHAR(255) DEFAULT ' ' NOT NULL,
FSERVICEDESC NVARCHAR(255) DEFAULT ' ' NOT NULL
);


/**发票供应商建索引语句 **/
 EXEC P_ALTERPK 'PK_T_ER_INVOICECLOUDPROVIDER', 'T_ER_INVOICECLOUDPROVIDER', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_INVOICEPROVIDER_FNUMBER') CREATE UNIQUE  CLUSTERED INDEX IDX_INVOICEPROVIDER_FNUMBER ON T_ER_INVOICECLOUDPROVIDER ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_ER_INVOICECLOUDPROVIDER_L', 'T_ER_INVOICECLOUDPROVIDER_L', 'FPKID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_INVOICEPROVIDER_L_FID') CREATE UNIQUE  CLUSTERED INDEX IDX_INVOICEPROVIDER_L_FID ON T_ER_INVOICECLOUDPROVIDER_L ( FID );


 EXEC P_ALTERPK 'PK_T_ER_INVOICESERVICEENTRY', 'T_ER_INVOICESERVICEENTRY', 'FENTRYID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_INVOICESERVICEENTRY_ID') CREATE UNIQUE  CLUSTERED INDEX IDX_INVOICESERVICEENTRY_ID ON T_ER_INVOICESERVICEENTRY ( FID );
