I cannot apologise enough for this:SELECT REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( REPLACE(REPLACE( SUBSTRING(Master.dbo.fn_varbintohexstr(OrderId),3,8), '0', 'x'), '1', 'y'), '2', '0010'), '3', '0011'), '4', '0100'), '5', '0101'), '6', '0110'), '7', '0111'), '8', '1000'), '9', '1001'), 'a', '1010'), 'b', '1011'), 'c', '1100'), 'd', '1101'), 'e', '1110'), 'f', '1111'), 'x', '0000'), 'y', '0001')FROM Northwind.dbo.Orders
(yes, of course it would make more sense to adapt fn_varbintohexstr)Edited by - Arnold Fribble on 12/02/2001 06:33:24