ALTER TABLE [dbo].[RDX_TALLAS]
ADD [TIPO_TALLAJE] smallint NULL
GO

update rdx_tallas
set TIPO_TALLAJE = 1
GO

insert into rdx_tallas (TALLA, TIPO_TALLAJE)
Values('S', 2)
GO

insert into rdx_tallas (TALLA, TIPO_TALLAJE)
Values('M', 2)
GO

insert into rdx_tallas (TALLA, TIPO_TALLAJE)
Values('L', 2)
GO

insert into rdx_tallas (TALLA, TIPO_TALLAJE)
Values('XL', 2)
GO

ALTER TABLE [dbo].[RDX_TRASPASOS_AJUSTES]
ADD [CANT_S] numeric(15, 0) NULL
GO

ALTER TABLE [dbo].[RDX_TRASPASOS_AJUSTES]
ADD [CANT_M] numeric(15, 0) NULL
GO

ALTER TABLE [dbo].[RDX_TRASPASOS_AJUSTES]
ADD [CANT_L] numeric(15, 0) NULL
GO

ALTER TABLE [dbo].[RDX_TRASPASOS_AJUSTES]
ADD [CANT_XL] numeric(15, 0) NULL
GO

ALTER TABLE [dbo].[RDX_RECEPCION_AJUSTES]
ADD [CANT_S] numeric(15, 0) NULL
GO

ALTER TABLE [dbo].[RDX_RECEPCION_AJUSTES]
ADD [CANT_M] numeric(15, 0) NULL
GO

ALTER TABLE [dbo].[RDX_RECEPCION_AJUSTES]
ADD [CANT_L] numeric(15, 0) NULL
GO

ALTER TABLE [dbo].[RDX_RECEPCION_AJUSTES]
ADD [CANT_XL] numeric(15, 0) NULL
GO

ALTER TABLE [dbo].[RDX_DEVOLUCION_AJUSTES]
ADD [CANT_S] numeric(15, 0) NULL
GO

ALTER TABLE [dbo].[RDX_DEVOLUCION_AJUSTES]
ADD [CANT_M] numeric(15, 0) NULL
GO

ALTER TABLE [dbo].[RDX_DEVOLUCION_AJUSTES]
ADD [CANT_L] numeric(15, 0) NULL
GO

ALTER TABLE [dbo].[RDX_DEVOLUCION_AJUSTES]
ADD [CANT_XL] numeric(15, 0) NULL
GO

CREATE PROCEDURE dbo.RDX_P_TIPO_TALLAJE
@PRODUCTO VARCHAR(12), @TIPO_TALLAJE smallint OUT
AS
BEGIN
     set @TIPO_TALLAJE = (SELECT DISTINCT RDX_TALLAS.TIPO_TALLAJE
     FROM PRODUTOS_BARRA
     LEFT JOIN RDX_TALLAS ON (PRODUTOS_BARRA.GRADE = RDX_TALLAS.TALLA)
     WHERE PRODUTOS_BARRA.PRODUTO = @PRODUCTO)
END
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



UPDATE RDX_CABINV
SET CARGADO = NULL;

UPDATE RDX_CABVEN
SET CARGADO = NULL;
GO


>>>>>>>>>>><LANZAR PROCEDIMIENTOS DE CARGA
