dbTalk Databases Forums  

How to Find Extended Characters in Text

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss How to Find Extended Characters in Text in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
HumanJHawkins
 
Posts: n/a

Default How to Find Extended Characters in Text - 11-10-2009 , 03:28 PM






Hi,

I need to find records where a text (and/or varchar) field contains
extended characters. If I knew particular extended characters, I could
do something like this:
select * from TableName where charindex('—',vchitem)<>0 or charindex
('°',vchitem)<>0

But I do not know what extended characters might be in the field, so I
need to do something like looking for text that contains an ASCII
value greater than 127 for example.

Can anyone think of how to do this?
Thanks in advance.

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: How to Find Extended Characters in Text - 11-12-2009 , 05:28 AM






HumanJHawkins (JHawkins (AT) Locutius (DOT) Com) writes:
Quote:
I need to find records where a text (and/or varchar) field contains
extended characters. If I knew particular extended characters, I could
do something like this:
select * from TableName where charindex('-',vchitem)<>0 or charindex
('',vchitem)<>0

But I do not know what extended characters might be in the field, so I
need to do something like looking for text that contains an ASCII
value greater than 127 for example.

Can anyone think of how to do this?
patindex('%[' + char(127) + '-' + char(255) + ']%',
col COLLATE Latin1_General_BIN2)

That is, by forcing a binary collection, you can use a range pattern.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
  #3  
Old   
HumanJHawkins
 
Posts: n/a

Default Re: How to Find Extended Characters in Text - 11-12-2009 , 12:37 PM



On Nov 12, 3:28*am, Erland Sommarskog <esq... (AT) sommarskog (DOT) se> wrote:
<CUT>
Quote:
patindex('%[' + char(127) + '-' + char(255) + ']%',
* * * * * col COLLATE Latin1_General_BIN2)

That is, by forcing a binary collection, you can use a range pattern.
Thanks. It worked perfectly (I used "Latin1_General_BIN" instead of
"Latin1_General_BIN2", as I'm on SQL2000)

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.