/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_CABINV]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_CABINV]
GO

CREATE TABLE [RDX_CABINV] (
  [NUMDOC] varchar(25) NOT NULL,
  [TIPODOC] varchar(3) NULL,
  [TIPOLIQ] varchar(3) NULL,
  [FECHA] datetime NULL,
  [FECHALIQ] datetime NULL,
  [EMISOR] varchar(17) NULL,
  [RECEPTOR] varchar(17) NULL,
  [DPTO] varchar(3) NULL,
  [CENTRO] varchar(17) NULL,
  [FECHA_CARGA] datetime NULL,
  [IGNORAR] varchar(1) NULL,
  [CARGADO] char(1) NULL
)
ON [PRIMARY]
GO

ALTER TABLE [RDX_CABINV]
ADD PRIMARY KEY CLUSTERED ([NUMDOC])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_CABINV_idx] ON [RDX_CABINV]
  ([FECHALIQ])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_CABINV_idx2] ON [RDX_CABINV]
  ([CENTRO])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_CABINV_idx3] ON [RDX_CABINV]
  ([IGNORAR])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_CABINV]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_LININV]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_LININV]
GO

CREATE TABLE [RDX_LININV] (
  [NUMDOC] varchar(25) NOT NULL,
  [NUMLIN] numeric(6, 0) NOT NULL,
  [CODART] varchar(17) NULL,
  [FAMILIA] varchar(17) NULL,
  [BARRA] varchar(17) NULL,
  [TALLA] varchar(17) NULL,
  [MARCA] varchar(25) NULL,
  [TAMANO] varchar(25) NULL,
  [SERIE] varchar(25) NULL,
  [COLOR] varchar(25) NULL,
  [MODELO] varchar(25) NULL,
  [DIBUJO] varchar(25) NULL,
  [DESCRIP] varchar(70) NULL
)
ON [PRIMARY]
GO

ALTER TABLE [RDX_LININV]
ADD PRIMARY KEY CLUSTERED ([NUMDOC], [NUMLIN])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_LININV_idx] ON [RDX_LININV]
  ([CODART])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_LININV]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_CANTINV]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_CANTINV]
GO

CREATE TABLE [RDX_CANTINV] (
  [NUMDOC] varchar(25) NOT NULL,
  [NUMLIN] numeric(6, 0) NOT NULL,
  [NUMCANT] numeric(6, 0) NOT NULL,
  [TIPOCANT] varchar(3) NULL,
  [CANTIDAD] numeric(15, 0) NULL,
  [CENTRO] varchar(17) NULL,
  [TMOV] varchar(3) NULL,
  [FACT] varchar(12) NULL,
  [DEPTO] varchar(3) NULL,
  [IDVEN] varchar(10) NULL
)
ON [PRIMARY]
GO

ALTER TABLE [RDX_CANTINV]
ADD PRIMARY KEY CLUSTERED ([NUMDOC], [NUMLIN], [NUMCANT])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_CANTINV_idx] ON [RDX_CANTINV]
  ([CENTRO])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_CANTINV_idx2] ON [RDX_CANTINV]
  ([TIPOCANT])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_CANTINV_idx3] ON [RDX_CANTINV]
  ([IDVEN])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_CANTINV]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_CABVEN]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_CABVEN]
GO

CREATE TABLE [RDX_CABVEN] (
  [CLAVE1] numeric(10, 0) NOT NULL,
  [NUMINF] varchar(35) NULL,
  [FUNCION] varchar(10) NULL,
  [FECINI] datetime NULL,
  [FECFIN] datetime NULL,
  [FECINF] datetime NULL,
  [PERVENINI] datetime NULL,
  [PERVENFIN] datetime NULL,
  [EANOFI] varchar(17) NULL,
  [EANEMI] varchar(17) NULL,
  [EANREC] varchar(17) NULL,
  [EANVEN] varchar(17) NULL,
  [EANALM] varchar(17) NULL,
  [EANREP] varchar(17) NULL,
  [EANPRO] varchar(17) NULL,
  [EANADMSA] varchar(17) NULL,
  [EANREPSR] varchar(17) NULL,
  [ADMVENSA] varchar(35) NULL,
  [REPDEPSR] varchar(35) NULL,
  [EMAILSA] varchar(35) NULL,
  [NUMFAXSA] varchar(35) NULL,
  [NUMTELSA] varchar(35) NULL,
  [NUMTLXSA] varchar(35) NULL,
  [X400SA] varchar(35) NULL,
  [EMAILSR] varchar(35) NULL,
  [NUMFAXSR] varchar(35) NULL,
  [NUMTELSR] varchar(35) NULL,
  [NUMTLXSR] varchar(35) NULL,
  [X400SR] varchar(35) NULL,
  [NUMPRE] varchar(35) NULL,
  [NUMINFSC] varchar(35) NULL,
  [NUMCON] varchar(35) NULL,
  [FECPRE] datetime NULL,
  [FECINFSC] datetime NULL,
  [FECCON] datetime NULL,
  [DIVPED] varchar(3) NULL,
  [DIVPRE] varchar(3) NULL,
  [DIVPAG] varchar(3) NULL,
  [DIVPEDF] varchar(3) NULL,
  [DIVPREF] varchar(3) NULL,
  [DIVPAGF] varchar(3) NULL,
  [TASCAM] numeric(15, 3) NULL,
  [FECTAS] datetime NULL,
  [FECHA_CARGA] datetime NULL,
  [IGNORAR] varchar(1) NULL,
  [CARGADO] char(1) NULL
)
ON [PRIMARY]
GO

ALTER TABLE [RDX_CABVEN]
ADD PRIMARY KEY CLUSTERED ([CLAVE1])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_CABVEN_idx] ON [RDX_CABVEN]
  ([NUMINF])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_CABVEN_idx2] ON [RDX_CABVEN]
  ([IGNORAR])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_CABVEN]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_LUGVEN]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_LUGVEN]
GO

CREATE TABLE [RDX_LUGVEN] (
  [CLAVE1] numeric(10, 0) NOT NULL,
  [CLAVE2] numeric(5, 0) NOT NULL,
  [EANLUG] varchar(17) NULL,
  [LUGVEN] varchar(70) NULL,
  [FECINI] datetime NULL,
  [FECFIN] datetime NULL,
  [PERVENINI] datetime NULL,
  [PERVENFIN] datetime NULL
)
ON [PRIMARY]
GO

ALTER TABLE [RDX_LUGVEN]
ADD PRIMARY KEY CLUSTERED ([CLAVE1], [CLAVE2])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_LUGVEN_PERVENINI_IDX] ON [RDX_LUGVEN]
  ([PERVENINI])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_LUGVEN_idx] ON [RDX_LUGVEN]
  ([EANLUG])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_LUGVEN]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_ARTVEN]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_ARTVEN]
GO

CREATE TABLE [RDX_ARTVEN] (
  [CLAVE1] numeric(10, 0) NOT NULL,
  [CLAVE2] numeric(5, 0) NOT NULL,
  [CLAVE3] numeric(5, 0) NOT NULL,
  [EANART] varchar(17) NULL,
  [CODCOM] varchar(35) NULL,
  [NUMVAR] varchar(35) NULL,
  [CODPRO] varchar(35) NULL,
  [DESARTCO] varchar(35) NULL,
  [DESART] varchar(70) NULL,
  [NUMCON] varchar(35) NULL,
  [NUMLIS] varchar(35) NULL,
  [CONESP1] varchar(3) NULL,
  [CONESP2] varchar(3) NULL,
  [CONESP3] varchar(3) NULL,
  [VALVEN] numeric(15, 3) NULL,
  [PRENETCT] numeric(15, 3) NULL,
  [PREBRUCT] numeric(15, 3) NULL,
  [PREINFET] numeric(15, 3) NULL,
  [PREINFFT] numeric(15, 3) NULL,
  [PRECALCT] numeric(15, 3) NULL,
  [PRENETCA] numeric(15, 3) NULL,
  [PREBRUCA] numeric(15, 3) NULL,
  [PREINFEA] numeric(15, 3) NULL,
  [PREINFFA] numeric(15, 3) NULL,
  [PRECALCA] numeric(15, 3) NULL,
  [BAPRUN1] numeric(9, 0) NULL,
  [UNIMED1] varchar(3) NULL,
  [BAPRUN2] numeric(9, 0) NULL,
  [UNIMED2] varchar(3) NULL,
  [BAPRUN3] numeric(9, 0) NULL,
  [UNIMED3] varchar(3) NULL,
  [BAPRUN4] numeric(9, 0) NULL,
  [UNIMED4] varchar(3) NULL,
  [BAPRUN5] numeric(9, 0) NULL,
  [UNIMED5] varchar(3) NULL,
  [CANVEN] numeric(15, 3) NULL,
  [EXIPRO] numeric(15, 3) NULL,
  [DESEXI] numeric(15, 3) NULL,
  [ESPMEDCV] varchar(3) NULL,
  [ESPMEDEP] varchar(3) NULL,
  [ESPMEDDE] varchar(3) NULL,
  [CANDEV] numeric(15, 3) NULL,
  [EANVEN] varchar(17) NULL,
  [NOMVEN] varchar(70) NULL,
  [NUMTALON] varchar(35) NULL,
  [CANVENNET] numeric(15, 3) NULL,
  [UMEDVENNET] varchar(3) NULL,
  [CANESP] numeric(15, 3) NULL,
  [UMEDESP] varchar(3) NULL
)
ON [PRIMARY]
GO

ALTER TABLE [RDX_ARTVEN]
ADD PRIMARY KEY CLUSTERED ([CLAVE1], [CLAVE2], [CLAVE3])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_ARTVEN_idx] ON [RDX_ARTVEN]
  ([EANART])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_ARTVEN_idx2] ON [RDX_ARTVEN]
  ([CODCOM])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_ARTVEN_idx4] ON [RDX_ARTVEN]
  ([NUMTALON])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_ARTVEN_idx5] ON [RDX_ARTVEN]
  ([EANVEN])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_ARTVEN]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_INFORMES]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_INFORMES]
GO

CREATE TABLE [RDX_INFORMES] (
  [ID] smallint IDENTITY(1, 1) NOT NULL,
  [CATEGORIA] varchar(15) NULL,
  [ICONO] smallint NULL,
  [NOMBRE] varchar(50) NULL,
  [DESCRIPCION] varchar(255) NULL,
  [ORDEN] smallint NULL,
  [VISTA] text NULL,
  [MODIFICABLE] char(1) CONSTRAINT [DF__RDX_INFOR__MODIF__5C78A0F0] DEFAULT 'S' NOT NULL
)
ON [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE [RDX_INFORMES]
ADD CONSTRAINT [RDX_INFORMES_pk] 
PRIMARY KEY CLUSTERED ([ID])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_INFORMES_idx] ON [RDX_INFORMES]
  ([CATEGORIA])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_INFORMES]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_LOG_CARGA]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_LOG_CARGA]
GO

CREATE TABLE [RDX_LOG_CARGA] (
  [ID] int IDENTITY(1, 1) NOT NULL,
  [REPORT] varchar(10) NOT NULL,
  [FECHA] datetime NOT NULL,
  [OK] bit NOT NULL,
  [ERROR_MSG] varchar(255) NULL
)
ON [PRIMARY]
GO

ALTER TABLE [RDX_LOG_CARGA]
ADD UNIQUE NONCLUSTERED ([ID])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_LOG_CARGA]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_REFERENCIA_GENERICA]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_REFERENCIA_GENERICA]
GO

CREATE TABLE [RDX_REFERENCIA_GENERICA] (
  [NUMINF] varchar(35) NOT NULL,
  [CLAVE1] numeric(10, 0) NOT NULL,
  [CLAVE2] numeric(5, 0) NOT NULL,
  [CLAVE3] numeric(5, 0) NOT NULL,
  [FECHACAMBIO] datetime NOT NULL,
  [ESTADO] char(1) NOT NULL,
  [CODIGO_BARRA] varchar(25) NULL,
  [CANVEN] numeric(15, 3) NULL,
  [CANESP] numeric(15, 3) NULL,
  [CANVENNET] numeric(15, 3) NULL,
  [NUMCON] smallint CONSTRAINT [DF__RDX_REFER__NUMCO__28C3F2C0] DEFAULT 0 NOT NULL,
  [VALVEN] numeric(15, 3) NULL
)
ON [PRIMARY]
GO

ALTER TABLE [RDX_REFERENCIA_GENERICA]
ADD CONSTRAINT [PK__RDX_REFERENCIA_G__68DE77D5] 
PRIMARY KEY CLUSTERED ([NUMINF], [CLAVE1], [CLAVE2], [CLAVE3], [NUMCON])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_REFERENCIA_GENERICA_idx] ON [RDX_REFERENCIA_GENERICA]
  ([FECHACAMBIO])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_REFERENCIA_GENERICA_idx2] ON [RDX_REFERENCIA_GENERICA]
  ([CODIGO_BARRA])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_REFERENCIA_GENERICA_idx3] ON [RDX_REFERENCIA_GENERICA]
  ([ESTADO])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_REFERENCIA_GENERICA]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_AJUSTES_ALBARAN]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_AJUSTES_ALBARAN]
GO

CREATE TABLE [RDX_AJUSTES_ALBARAN] (
  [ALBARAN] char(7) NOT NULL,
  [ESTADO] varchar(15) NULL,
  [OBSERVACIONES] varchar(255) NULL,
  [CONTABILIZAR] char(1) NULL
)
ON [PRIMARY]
GO

ALTER TABLE [RDX_AJUSTES_ALBARAN]
ADD CONSTRAINT [PK__RDX_AJUSTES_ALBA__1B69F7A2] 
PRIMARY KEY CLUSTERED ([ALBARAN])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_AJUSTES_ALBARAN_idx] ON [RDX_AJUSTES_ALBARAN]
  ([ESTADO])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_AJUSTES_ALBARAN_idx2] ON [RDX_AJUSTES_ALBARAN]
  ([CONTABILIZAR])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_AJUSTES_ALBARAN]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_AJUSTES_HOJA_DEVOLUCIONES]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_AJUSTES_HOJA_DEVOLUCIONES]
GO

CREATE TABLE [RDX_AJUSTES_HOJA_DEVOLUCIONES] (
  [NUMHOJA] char(8) NOT NULL,
  [ESTADO] varchar(20) NULL,
  [OBSERVACIONES] varchar(255) NULL,
  [CONTABILIZAR] char(1) CONSTRAINT [DF__RDX_AJUST__CONTA__7BF14C49] DEFAULT 'S' NULL
)
ON [PRIMARY]
GO

ALTER TABLE [RDX_AJUSTES_HOJA_DEVOLUCIONES]
ADD CONSTRAINT [PK__RDX_AJUSTES_HOJA__483C9E19] 
PRIMARY KEY CLUSTERED ([NUMHOJA])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_AJUSTES_HOJA_DEVOLUCIONES]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_DEVOLUCION_AJUSTES]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_DEVOLUCION_AJUSTES]
GO

CREATE TABLE [RDX_DEVOLUCION_AJUSTES] (
  [FECHA] datetime NOT NULL,
  [CENTRO] varchar(17) NOT NULL,
  [CODIGO] varchar(12) NOT NULL,
  [COLOR] varchar(10) NOT NULL,
  [APROBADO] char(1) NULL,
  [FECHACAMBIO] datetime NULL,
  [CANT38] numeric(15, 0) NULL,
  [CANT40] numeric(15, 0) NULL,
  [CANT42] numeric(15, 0) NULL,
  [CANT44] numeric(15, 0) NULL,
  [CANT46] numeric(15, 0) NULL,
  [CANT48] numeric(15, 0) NULL
)
ON [PRIMARY]
GO

ALTER TABLE [RDX_DEVOLUCION_AJUSTES]
ADD CONSTRAINT [PK_RDX_DEVOLUCION_AJUSTES_2F70F04A] 
PRIMARY KEY CLUSTERED ([FECHA], [CENTRO], [CODIGO], [COLOR])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_DEVOLUCION_AJUSTES_idx] ON [RDX_DEVOLUCION_AJUSTES]
  ([APROBADO])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_DEVOLUCION_AJUSTES_idx2] ON [RDX_DEVOLUCION_AJUSTES]
  ([FECHACAMBIO])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_DEVOLUCION_AJUSTES]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_RECEPCION_AJUSTES]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_RECEPCION_AJUSTES]
GO

CREATE TABLE [RDX_RECEPCION_AJUSTES] (
  [FECHA] datetime NOT NULL,
  [CENTRO] varchar(17) NOT NULL,
  [CODIGO] varchar(12) NOT NULL,
  [COLOR] varchar(10) NOT NULL,
  [APROBADO] char(1) NULL,
  [FECHACAMBIO] datetime NULL,
  [CANT38] numeric(15, 0) NULL,
  [CANT40] numeric(15, 0) NULL,
  [CANT42] numeric(15, 0) NULL,
  [CANT44] numeric(15, 0) NULL,
  [CANT46] numeric(15, 0) NULL,
  [CANT48] numeric(15, 0) NULL
)
ON [PRIMARY]
GO

ALTER TABLE [RDX_RECEPCION_AJUSTES]
ADD CONSTRAINT [PK_RDX_RECEPCION_AJUSTES_2F70F04F] 
PRIMARY KEY CLUSTERED ([FECHA], [CENTRO], [CODIGO], [COLOR])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_RECEPCION_AJUSTES_idx] ON [RDX_RECEPCION_AJUSTES]
  ([FECHACAMBIO])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_RECEPCION_AJUSTES_idx2] ON [RDX_RECEPCION_AJUSTES]
  ([APROBADO])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_RECEPCION_AJUSTES]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_TRASPASOS_AJUSTES]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_TRASPASOS_AJUSTES]
GO

CREATE TABLE [RDX_TRASPASOS_AJUSTES] (
  [FECHA] datetime NOT NULL,
  [CENTRO] varchar(17) NOT NULL,
  [CENTRO2] varchar(17) NOT NULL,
  [CODIGO] varchar(12) NOT NULL,
  [COLOR] varchar(10) NOT NULL,
  [APROBADO] char(1) NULL,
  [ESTADO] varchar(20) NULL,
  [OBSERVACIONES] varchar(255) NULL,
  [CONTABILIZAR] char(1) NULL,
  [FECHACAMBIO] datetime NULL,
  [CANT38] numeric(15, 0) NULL,
  [CANT40] numeric(15, 0) NULL,
  [CANT42] numeric(15, 0) NULL,
  [CANT44] numeric(15, 0) NULL,
  [CANT46] numeric(15, 0) NULL,
  [CANT48] numeric(15, 0) NULL,
  [TIPOCANT] varchar(3) NOT NULL
)
ON [PRIMARY]
GO

ALTER TABLE [RDX_TRASPASOS_AJUSTES]
ADD CONSTRAINT [PK_RDX_TRASPASOS_AJUSTES_2F70F04A] 
PRIMARY KEY CLUSTERED ([FECHA], [CENTRO], [CENTRO2], [CODIGO], [COLOR])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_TRASPASOS_AJUSTES_idx] ON [RDX_TRASPASOS_AJUSTES]
  ([APROBADO])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_TRASPASOS_AJUSTES_idx2] ON [RDX_TRASPASOS_AJUSTES]
  ([ESTADO])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_TRASPASOS_AJUSTES_idx3] ON [RDX_TRASPASOS_AJUSTES]
  ([FECHACAMBIO])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_TRASPASOS_AJUSTES]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_FILIALES]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_FILIALES]
GO

CREATE TABLE [RDX_FILIALES] (
  [CODFILIAL] char(6) NULL,
  [CODBARRA] varchar(17) NULL
)
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_FILIALES_idx] ON [RDX_FILIALES]
  ([CODBARRA])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_FILIALES_idx2] ON [RDX_FILIALES]
  ([CODFILIAL])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_FILIALES]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_TALLAS]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_TALLAS]
GO

CREATE TABLE [RDX_TALLAS] (
  [TALLA] char(2) NOT NULL
)
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_TALLAS_idx] ON [RDX_TALLAS]
  ([TALLA])
ON [PRIMARY]
GO


GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_TALLAS]
TO [public]
GO


/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[RDX_INVENTARIOEDI]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_INVENTARIOEDI]
GO

CREATE TABLE [RDX_INVENTARIOEDI] (
  [NUMDOC] varchar(25) NOT NULL,
  [NUMLIN] numeric(6, 0) NOT NULL,
  [NUMCANT] numeric(6, 0) NOT NULL,
  [TIPOCANT] varchar(3) NULL,
  [FECHA] datetime NULL,
  [CENTRO] varchar(17) NULL,
  [FILIAL] varchar(25) NULL,
  [CODVEN] varchar(10) NULL,
  [VENDEDOR] varchar(66) NULL,
  [CODIGO_BARRA] varchar(17) NULL,
  [CODIGO] varchar(12) NULL,
  [PRODUCTO] varchar(40) NULL,
  [COLOR] varchar(10) NULL,
  [TALLA] varchar(8) NULL,
  [CANTIDAD] numeric(15, 0) NULL,
  [CENTRO2] varchar(17) NULL,
  [FILIAL2] varchar(25) NULL,
  [ULTIMO_INVENTARIO] char(1) NULL,
  [IGNORAR] char(1) NULL
)
ON [PRIMARY]
GO

ALTER TABLE [RDX_INVENTARIOEDI]
ADD CONSTRAINT [RDX_INVENTARIOEDI_pk] 
PRIMARY KEY CLUSTERED ([NUMDOC], [NUMLIN], [NUMCANT])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_INVENTARIOEDI_idx] ON [RDX_INVENTARIOEDI]
  ([TIPOCANT])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_INVENTARIOEDI_idx2] ON [RDX_INVENTARIOEDI]
  ([FECHA])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_INVENTARIOEDI_idx3] ON [RDX_INVENTARIOEDI]
  ([CENTRO])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_INVENTARIOEDI_idx4] ON [RDX_INVENTARIOEDI]
  ([CODVEN])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_INVENTARIOEDI_idx5] ON [RDX_INVENTARIOEDI]
  ([CODIGO_BARRA])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_INVENTARIOEDI_idx6] ON [RDX_INVENTARIOEDI]
  ([CODIGO])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_INVENTARIOEDI_idx7] ON [RDX_INVENTARIOEDI]
  ([CENTRO2])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_INVENTARIOEDI_idx8] ON [RDX_INVENTARIOEDI]
  ([ULTIMO_INVENTARIO])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_INVENTARIOEDI_idx9] ON [RDX_INVENTARIOEDI]
  ([CENTRO], [CODIGO], [COLOR], [TALLA])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_INVENTARIOEDI]
TO [public]
GO

/*--------------- SQL ---------------*/

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[RDX_VENTASEDI]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
  DROP TABLE [RDX_VENTASEDI]
GO

CREATE TABLE [RDX_VENTASEDI] (
  [NUMINF] varchar(35) NOT NULL,
  [CLAVE1] numeric(10, 0) NOT NULL,
  [CLAVE2] numeric(5, 0) NOT NULL,
  [CLAVE3] numeric(5, 0) NOT NULL,
  [PERVENINI] datetime NULL,
  [NUMTALON] varchar(35) NULL,
  [EANLUG] varchar(17) NULL,
  [FILIAL] varchar(25) NULL,
  [EANVEN] varchar(17) NULL,
  [CODVEN] varchar(4) NULL,
  [VENDEDOR] varchar(66) NULL,
  [EANART] varchar(17) NULL,
  [CODCOM] varchar(35) NULL,
  [PRODUTO] varchar(12) NULL,
  [DESC_PRODUTO] varchar(40) NULL,
  [COR_PRODUTO] varchar(10) NULL,
  [GRADE] varchar(8) NULL,
  [TIPO_PRODUTO] varchar(25) NULL,
  [GRUPO_PRODUTO] varchar(25) NULL,
  [DESC_COLECAO] varchar(40) NULL,
  [VALVEN] numeric(15, 3) NULL,
  [CANVEN] numeric(15, 3) NULL,
  [CANDEV] numeric(15, 3) NULL,
  [CANVENNET] numeric(15, 3) NULL,
  [CANESP] numeric(15, 3) NULL,
  [IGNORAR] char(1) NULL
)
ON [PRIMARY]
GO

ALTER TABLE [RDX_VENTASEDI]
ADD CONSTRAINT [RDX_VENTASEDI_pk] 
PRIMARY KEY CLUSTERED ([NUMINF], [CLAVE1], [CLAVE2], [CLAVE3])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_VENTASEDI_idx] ON [RDX_VENTASEDI]
  ([PERVENINI])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_VENTASEDI_idx2] ON [RDX_VENTASEDI]
  ([NUMTALON])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_VENTASEDI_idx3] ON [RDX_VENTASEDI]
  ([EANVEN])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_VENTASEDI_idx4] ON [RDX_VENTASEDI]
  ([CODVEN])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_VENTASEDI_idx5] ON [RDX_VENTASEDI]
  ([EANART])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_VENTASEDI_idx6] ON [RDX_VENTASEDI]
  ([CODCOM])
ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [RDX_VENTASEDI_idx7] ON [RDX_VENTASEDI]
  ([PRODUTO])
ON [PRIMARY]
GO

GRANT SELECT, INSERT, DELETE, REFERENCES, UPDATE
ON [RDX_VENTASEDI]
TO [public]
GO

/* EOF */


