Just a quick one in case I forget – I had a scenario where I needed to replace fn_varbintohexstr in converting an existing product to something more Azure SQL DB friendly.
I did some googling and didn’t like the results, especially since most of them are returning NVARCHAR(MAX) instead of what they generally should – just VARCHAR(length of data) and in the case of my needs (timestamps) the value was always 18 characters.
The key was finding the conversion to binary first, and then the use of the ,1 param for convert.
select convert(varchar(18), convert(varbinary(18), row_version), 1)
That’s all folks.