19

How to search hexadecimal characters from a SQL Server table? Actually I tried like below but it is searching all zeroes in the field.

select Email,* 
from address 
where CHARINDEX(convert(varchar, Ascii(0x00)), Email) > 0

Thanks

1
  • 1
    Can you give an example of what you want to find? What would be a match, what wouldn't? Commented Aug 3, 2012 at 12:20

1 Answer 1

48

I had a similar problem where a hexadecimal character was crashing a query. This is what I did to find it.

select Email
from address
where Email like '%' + CHAR(0x00) +'%'

Now to stop the bad data getting in in the first place...

Sign up to request clarification or add additional context in comments.

1 Comment

This is the correct answer, at least for a similar problem I was having (illegal XML characters).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.