Looking to convert an integer to the hex string equivalent using TSQL
1 = 1
10 = A
100 = 64
1000 = 3E8
etc.
SO FAR the solution seems to be
DECLARE @str VARCHAR(10)
SELECT @str = sys.fn_varbintohexstr(CONVERT(VARBINARY, @num))
IF @num < 16
SELECT @str = RIGHT(@str, 1)
ELSE IF @num < 256
SELECT @str = RIGHT(@str, 2)
ELSE IF @num < 4096
SELECT @str = RIGHT(@str, 3)
ELSE -- and so on
SELECT @str = RIGHT(@str, 4)
RETURN @str
but someone this seems a little klutzy, is there a better way ?