Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Finding Non-standard characters in a SQL Server table

Posted on 2009-04-02
6
Medium Priority
?
327 Views
Last Modified: 2012-05-06
A bug in one of our import processes allowed non-standard characters (like Ö]¡]ÐÉ]¿)  to get imported into one of our tables.  The characters can appear at the end of a string of standard characters or they can appear in the middle of the string.   There may be only 1 non-standard character in the field, or multiple non-standard characters.  I'm not really sure which non-standard characters were included, so I can't just search for a particular character.  I need to find anything that's not A-Z or 0-9, and not a comma, apostrophe, number sign, bracket, parentheses, or other standard symbol in American English.

I need to find the records that are affected.  Is there a query I can run that will detect these non-standard characters?  I don't want to replace them yet, just to identify the affected records.
0
Comment
Question by:n f
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24055663
this should do:
select * from yourtable
where yourfield like '%[^A-Za-z0-9]%'

Open in new window

0
 
LVL 1

Author Comment

by:n f
ID: 24060917
I tried angelll's code, but it returned records with no special characters as well as records with special characters.  Does '%[^A-Za-z0-9]%' include spaces?
0
 
LVL 1

Author Comment

by:n f
ID: 24060983
An example of some of the fields returned by angelll's code (there were many, many more)::

VALDOSTA�
ST JOHN'S
MT PEARL N
GRAND-M�RE QC G9T 2
TROIS-RIVI�RESQC G8T
NEW ALEXANDRIA
N HUNTINGDON
MT PLEASANT

Only
VALDOSTA�
GRAND-M�RE QC G9T 2
and
TROIS-RIVI�RESQC G8T
really have the special characters.

These three examples all have special characters "�".  I know those characters are in my table, but I need to find out if any others exist.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 24060984
if spaces should be allowed, add the space in the expression.
if you need any other character, just add it.

select * from yourtable
where yourfield like '%[^A-Za-z0-9 ]%'

Open in new window

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24060988
for example, single quotes:
select * from yourtable
where yourfield like '%[^A-Za-z0-9 '']%'

Open in new window

0
 
LVL 1

Author Closing Comment

by:n f
ID: 31566056
That did it!  Thanks!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question