Never mind... can't wait for an answer. Here's 95% of the solution. All you have to do is figure out how you actually want to format the 0-255 numbers in the final column. Do note that the ASCII function works just fine for characters over 127. You just have to be careful to only pass it 1 character at a time.
--=============================================================================
-- Create some test data. This is NOT a part of the solution
--=============================================================================
--===== Conditionally drop the test table to make reruns easier
IF OBJECT_ID('tempdb..#MyHead','U') IS NOT NULL
DROP TABLE #MyHead
;
--===== Build and populate the test table on the fly
WITH
cteBuild3CharData AS
( --=== Builds 3 random characters and a random 1-3 length
SELECT TOP 100000
WierdData = CAST(CHAR(ABS(CHECKSUM(NEWID()))%256) AS VARCHAR(3))
+ CAST(CHAR(ABS(CHECKSUM(NEWID()))%256) AS VARCHAR(3))
+ CAST(CHAR(ABS(CHECKSUM(NEWID()))%256) AS VARCHAR(3)),
RandomLen = ABS(CHECKSUM(NEWID()))%3+1
FROM sys.all_columns ac1,
sys.all_columns ac2
) --=== Use the random length to determine how long a string to save
-- and put it all in the test table
SELECT WierdData = SUBSTRING(WierdData,1,RandomLen)
INTO #MyHead
FROM cteBuild3CharData
;
--=============================================================================
-- In the absence of clear requirements, solve most of the problem.
--=============================================================================
--===== Display the Original data and 0-255 for each available character
SELECT WierdData,
Character1 = ASCII(SUBSTRING(WierdData,1,1)),
Character2 = ASCII(SUBSTRING(WierdData,2,1)),
Character3 = ASCII(SUBSTRING(WierdData,3,1))
FROM #MyHead
;
--Jeff Moden
Change is inevitable... Change for the better is not.