IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_CUSTOMER_B') 
 CREATE TABLE T_BD_CUSTOMER_B (
FID BIGINT DEFAULT 0 NOT NULL,
FCOUNTRYID BIGINT DEFAULT 0 NOT NULL,
FSOCIETYCREDITCODE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FTXREGISTERNO NVARCHAR(255) DEFAULT ' ' NOT NULL,
FESTABLISHDATE DATETIME,
FPHONE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FFAX NVARCHAR(40) DEFAULT ' ' NOT NULL,
FPOSTALCODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FURL NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINTERNALCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FADMINDIVISION NVARCHAR(100) DEFAULT ' ' NOT NULL,
FORGCODE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBIZREGISTERNO NVARCHAR(255) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER_L' AND KSQL_COL_NAME ='FADDRESS') 
 ALTER TABLE T_BD_CUSTOMER_L ADD (FADDRESS NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER_L' AND KSQL_COL_NAME ='FARTIFICIALPERSON') 
 ALTER TABLE T_BD_CUSTOMER_L ADD (FARTIFICIALPERSON NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER_L' AND KSQL_COL_NAME ='FREGCAPITAL') 
 ALTER TABLE T_BD_CUSTOMER_L ADD (FREGCAPITAL NVARCHAR(40) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER_L' AND KSQL_COL_NAME ='FBUSINESSTERM') 
 ALTER TABLE T_BD_CUSTOMER_L ADD (FBUSINESSTERM NVARCHAR(60) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER_L' AND KSQL_COL_NAME ='FBUSINESSSCOPE') 
 ALTER TABLE T_BD_CUSTOMER_L ADD (FBUSINESSSCOPE NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER_L' AND KSQL_COL_NAME ='FLINKMAN') 
 ALTER TABLE T_BD_CUSTOMER_L ADD (FLINKMAN NVARCHAR(60) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER' AND KSQL_COL_NAME ='FTYPE') 
 ALTER TABLE T_BD_CUSTOMER ADD (FTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER' AND KSQL_COL_NAME ='FBIZFUNCTION') 
 ALTER TABLE T_BD_CUSTOMER ADD (FBIZFUNCTION NVARCHAR(30) DEFAULT ',1,2,3,4,' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER' AND KSQL_COL_NAME ='FBLOCKEDORDER') 
 ALTER TABLE T_BD_CUSTOMER ADD (FBLOCKEDORDER CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER' AND KSQL_COL_NAME ='FBLOCKEDSHIPMENT') 
 ALTER TABLE T_BD_CUSTOMER ADD (FBLOCKEDSHIPMENT CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER' AND KSQL_COL_NAME ='FPAYMENTCURRENCY') 
 ALTER TABLE T_BD_CUSTOMER ADD (FPAYMENTCURRENCY BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER' AND KSQL_COL_NAME ='FINVOICETYPE') 
 ALTER TABLE T_BD_CUSTOMER ADD (FINVOICETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER' AND KSQL_COL_NAME ='FINVOICEHOLD') 
 ALTER TABLE T_BD_CUSTOMER ADD (FINVOICEHOLD CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER' AND KSQL_COL_NAME ='FINVOICEADDRESS') 
 ALTER TABLE T_BD_CUSTOMER ADD (FINVOICEADDRESS BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMERLINKMAN' AND KSQL_COL_NAME ='FROLE') 
 ALTER TABLE T_BD_CUSTOMERLINKMAN ADD (FROLE NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMERLINKMAN' AND KSQL_COL_NAME ='FINVALID') 
 ALTER TABLE T_BD_CUSTOMERLINKMAN ADD (FINVALID CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_BIZPARTNER' AND KSQL_COL_NAME ='FIDNO') 
 ALTER TABLE T_BD_BIZPARTNER ADD (FIDNO NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER_B' AND KSQL_COL_NAME ='FIDNO') 
 ALTER TABLE T_BD_CUSTOMER_B ADD (FIDNO NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_SUPPLIER_B' AND KSQL_COL_NAME ='FIDNO') 
 ALTER TABLE T_BD_SUPPLIER_B ADD (FIDNO NVARCHAR(50) DEFAULT ' ' NOT NULL );