FELIPE BUEN DIA,
UNA DISCULPA CON RESPECTO A ESTE TEMA CUANDO SUBO MI FUNCION A SAP EN QUERY MANAGER ME EMITE ALGUNOS ERRORES.
TE ADJUNTO MI QUERY PARA TU APOYO POR FAVOR, MUCHAS GRACIAS
ALTER Function Numeros(@str varchar(200))
returns varchar(100)
as begin
declare
@cuenta tinyint
,@numeros varchar(100)
,@num int
set @numeros = ''
set @cuenta = 1
set @num = 0
while (@cuenta < 200)
begin
if substring(@str, @cuenta,1) in ('0','1','2','3','4','5','6','7','8','9')
set @numeros = @numeros + substring(@str, @cuenta,1)
set @cuenta=@cuenta+1
end
return @numeros
end
go
Select
distinct T0.DocNum as 'ENTREGAS',
(dbo.Numeros(SUBSTRING(T0.Comments,(CHARINDEX('Pedidos',T0.Comments)+19),5))) +
(dbo.Numeros(SUBSTRING(T0.Comments,(CHARINDEX('Sales',T0.Comments)+13),5))) as 'PEDIDOS',
Convert(char(10),t0.DocDate, 103)as 'FECHA ENTREGA',
T0.Comments as 'COMENTARIOS',
T0.U_logentrega AS 'LOGISTICA ENTREGA',
T0.U_fechaEmbarqueMHO AS 'FECHA EMBARQUE',
T0.U_noGuia AS 'NO. GUIA',
Case T0.U_destino
when '01' then 'EATON' when '02' then 'FORT WAYNE' when '03' then 'SHREVEPORT' when '04' then 'MIAMI' when '05' then 'MEXICO'
when '06' then 'EDO.MEXICO' when '07' then 'GUADALAJARA' when '08' then 'SPRINGFIELD' when '09' then 'MONTERREY' when '10' then 'PUEBLA'
when '100' then 'SPARTANBURG' when '101' then 'TULARE' when '102' then 'FT.LAUDERDALE' when '103' then 'CRESTON' when '104' then 'BURLINGTON'
when '105' then 'ELGIN' when '106' then 'LINIER BEAUCE' when '107' then 'NINGBO' when '108' then 'GRIFFIN' when '109' then 'FAIRFAX'
when '11' then 'VERNON HILLS' when '110' then 'MOORESVILLE'
end as 'DESTINO',
Case T0.U_transportista
when '00' then 'CLIENTE RECOJE EN OFNA'
when '01' then 'CAMIONETA MHO'
when '02' then 'CAMIONETA SFT'
when '03' then 'CAMIONETA Marin'
when '04' then 'PAQ. EXPRESS'
when '05' then 'FLETES GDL-MERIDA'
when '06' then 'EASO CONSOLIDADO'
when '07' then 'TRANSPORTES CALAFIA'
when '08' then 'TRANSPORTES CULIACAN'
when '09' then 'TRANSPORTES 3 GUERRAS'
when '10' then 'JULIAN DE OBREGON'
when '11' then 'EASO MTY'
when '12' then 'EASO GDL'
when '13' then 'EASO MEX'
when '14' then 'TRANSPORTES ALMEX'
when '15' then 'DHL'
when '16' then 'AEROMEXPRESS'
when '17' then 'ESTAFETA'
when '18' then 'TRANSP UNIDOS TAMPIQUENOS'
when '19' then 'REDPACK'
when '20' then 'TRANSP UNIDOS TAMPIQUENOS'
when '21' then 'AGENTE ADUANAL'
when '22' then 'INNOVATIVOS'
when '23' then 'CAMION COMPLETO'
when '24' then 'ESTRELLA BLANCA'
when '25' then 'TRANSP MERCURIO'
<