IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INVRELATIONSET') 
 CREATE TABLE T_BCM_INVRELATIONSET (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FDIRECTEOWN INT DEFAULT 0 NOT NULL,
FINDIREOWNSUM INT DEFAULT 0 NOT NULL,
FINDIREOWNMUL INT DEFAULT 0 NOT NULL,
FINSHAREEOWN INT DEFAULT 0 NOT NULL,
FINTRASHAREEOWN INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INVRELATIONDEFINE') 
 CREATE TABLE T_BCM_INVRELATIONDEFINE (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDEFINEEOWN NVARCHAR(100) DEFAULT ' ' NOT NULL,
FISSELECTED INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INVRELATIONDEFINE_L') 
 CREATE TABLE T_BCM_INVRELATIONDEFINE_L (
FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);




IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_INVRELATIONDEFINE_L' AND KSQL_COL_NAME ='FENTRYID') 
 ALTER TABLE T_BCM_INVRELATIONDEFINE_L ADD (FENTRYID BIGINT DEFAULT 0 NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_INVRELATIONDEFINE_L', 'FID', 'NULL', 'NULL', '1001', 'NULL';