I am trying to insert a record with 3 digits, example: if it is the first one that comes out 001 and the consecutive one is 002, when reaching 10! let 010 come out.
in my code what I achieve is that I insert it without the two zeros
declare @Resultado int
SELECT @Resultado = SUBSTRING(MAX(Agente), CHARINDEX('V', MAX(Agente)) + 1, 4) + 1
FROM Agente
WHERE Agente LIKE '%204%'
AND Tipo = 'Agente'
print @Resultado
insert into Agente
(Agente, Nombre, Estatus, Conciliar, Nomina, Logico1, Logico2, Equipo)
values
('204V' + Convert(varchar, @Resultado), 'Lalo Garcia', 'ALTA', 1, 1, 0, 0, 0)
end
I hope you can support me.