Solved

Selecting special characters

Posted on 2004-08-23
3
682 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

707 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

12 Experts available now in Live!

Get 1:1 Help Now