November 12, 2019 at 12:00 am
Comments posted to this topic are about the item ASCII Text Dump
November 12, 2019 at 8:57 am
Suppose you have column ID in table T. Try the following:
Select ID, CAST(ID as Varbinary(255)) as Hex From T.
I find this to be sufficient in almost every case (and I strongly prefer to see the values in hex!).
November 12, 2019 at 2:32 pm
Suppose you have column ID in table T. Try the following:
Select ID, CAST(ID as Varbinary(255)) as Hex From T.
I find this to be sufficient in almost every case (and I strongly prefer to see the values in hex!).
Just my 2 cents. Normally, I'm looking for characters out of the ordinary. I also normally have a whole lot of data in files that I want to import or already have imported to check. I don't want to be eyeballing literally a billion or more hexadecimal bytes of information. The method in the article and the cast, in the absence of everything else, would require such eyeballing.
That being said, why not just bring a Tally function into play an let the computer quickly isolate that which you've been eyeballing? Here's a very simple example for just one string.
DECLARE @SomeString VARCHAR(MAX) = 'The quick brown fox jumpedá over the lazy dogs.
You should haveseen what the cats did.'
;
SELECT StringPosition = t.N
,Character = SUBSTRING(@SomeString,t.N,1)
,ASCII_Dec = RIGHT(1000+ASCII(SUBSTRING(@SomeString,t.N,1)),3)
,ASCII_Hex = CONVERT(CHAR(2),CONVERT(BINARY(1),(SUBSTRING(@SomeString,t.N,1))),2)
FROM dbo.fnTally(1,DATALENGTH(@SomeString)) t
WHERE ASCII(SUBSTRING(@SomeString,t.N,1)) NOT BETWEEN 32 AND 126
;
Here are the results from that code.
If you don't already have a "Tally" function, the one I use for production code is at the link in my signature line below.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 15, 2021 at 4:01 pm
Interesting article. Thanks
January 16, 2021 at 12:25 am
I use a tally table (cte)..
declare @txt nvarchar(max) = N'The quick brown fox jumpedá over the lazy dogs.'
; with nums as (
select top (len(@txt)) row_number() over (order by (select 1)) as num
from syscolumns, syscolumns a
)
select * from (
select num, substring(@txt,num,1) chr, ascii(substring(@txt,num,1)) as chrascii
from nums
) t
where not chrascii between 65 and 127
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply