Friday, February 24, 2012

Find all chars in table that are ASCII code 128 and Greater

Does anyone know how to query a field in a table where it contains an
ASCII code >= 128 - without looping through every field for every
record in table (using charindex)?

Ex of char I would like to find: which is char(252)DennBen (dbenedett@.hotmail.com) writes:

Quote:

Originally Posted by

Does anyone know how to query a field in a table where it contains an
ASCII code >= 128 - without looping through every field for every
record in table (using charindex)?
>
Ex of char I would like to find: which is char(252)


select *
from tbl
where col COLLATE Latin1_General_BIN
LIKE '%[^' + char(32) + '-' + char(126) + ']%'

If you want to run this for many in columns in many tables, you
will to run the query once per column and table.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

No comments:

Post a Comment