IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_BUSICARDINFO')
CREATE TABLE T_ER_BUSICARDINFO (
                                   FID BIGINT DEFAULT 0 NOT NULL,
                                   FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
                                   FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                   FSERVER BIGINT DEFAULT 0 NOT NULL,
                                   FUSER BIGINT DEFAULT 0 NOT NULL,
                                   FACCOUT VARCHAR(50) DEFAULT ' ' NOT NULL,
                                   FCARDNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
                                   FACTIVATIONDATE DATETIME,
                                   FCANCELDATE DATETIME,
                                   FACTIVATIONCODE VARCHAR(50) DEFAULT ' ' NOT NULL,
                                   FCIRCULATIONFLAG VARCHAR(50) DEFAULT ' ' NOT NULL,
                                   FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                   FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                   FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                   FENABLE VARCHAR(50) DEFAULT ' ' NOT NULL,
                                   FSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
                                   FCOMPANY BIGINT DEFAULT 0 NOT NULL,
                                   FDEPT BIGINT DEFAULT 0 NOT NULL
);


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



EXEC P_ALTERPK 'PK_T_ER_BUSICARDINFO', 'T_ER_BUSICARDINFO', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FUER') CREATE  CLUSTERED INDEX IDX_FUER ON T_ER_BUSICARDINFO ( FUSER );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_SERVER') CREATE INDEX IDX_SERVER ON T_ER_BUSICARDINFO ( FSERVER );


EXEC P_ALTERPK 'PK_T_ER_BUSICARDINFO_L', 'T_ER_BUSICARDINFO_L', 'FPKID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BUSICARDINFO_FID') CREATE  CLUSTERED INDEX IDX_BUSICARDINFO_FID ON T_ER_BUSICARDINFO_L ( FID );