Bueno, esto es una adaptacion. Solo queda lo del la funcion delete.
Código SQL:
Ver originalCREATE FUNCTION AzaleaI2of5(@I2of5number VARCHAR(50))
RETURNS VARCHAR(50)
AS
BEGIN
DECLARE @i INT,
@temp VARCHAR(10),
@temp2 VARCHAR(10)
@chunk VARCHAR(50)
IF (Len(@I2of5number) % 2) <> 0
SET @I2of5number = '0' + @I2of5number
SET @temp2 = @I2of5number
FOR @i = 1 TO Len(@I2of5number) / 2
BEGIN
SET @chunk = @temp2
SET @chunk = DELETE(@chunk, 3, Len(@chunk))
IF StrToInt(@chunk) < 90
SET @temp = @temp + Chr(StrToInt(@chunk) + 33)
ELSE
SET @temp = @temp + Chr(StrToInt(@chunk) + 71);
SET @temp2 = DELETE(@temp2, 1, 2)
END;
//ADD the START AND stop bars (ASCII 171 & ASCII 172)
RETURN Chr(171) + @temp + Chr(172)
END