Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL server - how to find Hexadecimal character in a table

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

like image 630
Pradeep Avatar asked Aug 03 '12 11:08

Pradeep


1 Answers

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...

like image 150
ChrisH Avatar answered Oct 05 '22 10:10

ChrisH