Solved

Selecting special characters

Posted on 2004-08-23
3
686 Views
Last Modified: 2008-01-16
Hello,

I have a number of columns in my dataset one/or more of which I believe might have an embedded special character such as a CR or LF. I have tried using the following in my query:

patindex('%' + char(13) + '%' , texfield) > 0 to no avail. I have also tried charindex with the same result.

I know that the special character is there because when I export the data out to text somewhere along the way the records gets truncated into two.

I would like to be able to locate this special character and strip it out. Any suggestions.

My next step is to write a VB program to go through the dataset.

Thanks
Eddie
0
Comment
Question by:ejr19592004
  • 2
3 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 11877456
Try something like this:
PATINDEX('%[^0-9][^A-Z][^a-z]%', textfield) > 0

To give you non-alpha-numeric characters.

Or to give you non-printable characters, something like:
PATINDEX('%[^ - Ç]%', textfield) > 0
0
 

Author Comment

by:ejr19592004
ID: 11877838
ACPerkins,

Thanks for your quick response. Is the line
PATINDEX('%[^0-9][^A-Z][^a-z]%', textfield) > 0
meant to look for anything that is not 0-9 A-Z and a-z ?

ejr19592004
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 75 total points
ID: 11877943
Yes.  Unfortunately it gets more complicated as I have discovered with other ranges.  Please disregard the second "solution" it is incorrect. For some reason that I have not managed to ascertain, it simply does not function (at least for me) with anything beyond the trivial non alphanumeric characters.

You may have to resort to using a cursor and cycle through all the rows. Looking for non-printable characters. Ugh!

Hopefully, someone will step in.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how the fundamental information of how to create a table.

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now