SQL Server : how to convert binary back to int
问题 Admin of our IS stored 8 flags like '00010000' (only true and false) to SQL Server as binary(2) . In this format data has values like '0x1000'. Is possible to convert this binary back to '00010000' ? Convert , Cast , Substring don't work. 回答1: Query returns hexadecimal number (0x... - it is hexadecimal) as its bit mask CREATE TABLE #Temp( Test VARBINARY(2) ) INSERT #Temp VALUES (0x1001), (0x3001), (0x5000), (0x6000), (0xf000), (0xf250) SELECT *, REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE