Home All Groups Group Topic Archive Search About
Author
14 Jul 2006 11:42 PM
JTL
is there a function in sql server that will check a string for illegal
characters?  i have a column that sometimes contains values like:
? ???¦++++S+n¦÷+¦ú¼-·+½+-+-¦p++¦÷¦÷¦-ú+ú¼-¦°-«¦+¦«¦-+¡--+++Ñúí+¦

i want to clean this table by deleting records that have these types of
characters- does this have something to do with unicode format?

tia

Author
15 Jul 2006 4:55 AM
sa
Simply use the replace function as follow:
replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(
        YourColumnName,
          '-',''),' ',''),'~',''),'!',''),'@',''),'#',''),'$',''),'%',''),
          '^',''),'&',''),'*',''),'(',''),')',''),'_',''),'+',''),
          '`',''),'=',''),',',''),'.',''),'/',''),'?',''),'"',''),
          ';',''),':',''),'[',''),']',''),'{',''),'}',''),char(39),''))

sa



JTL wrote:
Show quote
> is there a function in sql server that will check a string for illegal
> characters?  i have a column that sometimes contains values like:
> ? ???¦++++S+n¦÷+¦ú¼-·+½+-+-¦p++¦÷¦÷¦-ú+ú¼-¦°-«¦+¦«¦-+¡--+++Ñúí+¦
>
> i want to clean this table by deleting records that have these types of
> characters- does this have something to do with unicode format?
>
> tia
Author
15 Jul 2006 6:06 AM
cn.popeye
my god!!!

"sa" <suacha***@gmail.com>
??????:1152939355.056237.319***@b28g2000cwb.googlegroups.com...
Simply use the replace function as follow:
replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(
YourColumnName,
      '-',''),' ',''),'~',''),'!',''),'@',''),'#',''),'$',''),'%',''),
      '^',''),'&',''),'*',''),'(',''),')',''),'_',''),'+',''),
      '`',''),'=',''),',',''),'.',''),'/',''),'?',''),'"',''),
      ';',''),':',''),'[',''),']',''),'{',''),'}',''),char(39),''))

sa



JTL wrote:
Show quote
> is there a function in sql server that will check a string for illegal
> characters?  i have a column that sometimes contains values like:
> ? ???¦++++S+n¦÷+¦ú¼-·+½+-+-¦p++¦÷¦÷¦-ú+ú¼-¦°-«¦+¦«¦-+¡--+++Ñúí+¦
>
> i want to clean this table by deleting records that have these types of
> characters- does this have something to do with unicode format?
>
> tia
Author
15 Jul 2006 10:59 AM
Stu
As long as you are certain that these characters are illegal as a
singularity (in other words a single question mark hould trigger your
data cleansing process), you can use like and set delimiter, eg:

SELECT *
FROM Table
WHERE Column LIKE '%[?¦+¼]%'

If this is not the case, google SQL Server and RegEx.

HTH,
Stu



JTL wrote:
Show quote
> is there a function in sql server that will check a string for illegal
> characters?  i have a column that sometimes contains values like:
> ? ???¦++++S+n¦÷+¦ú¼-·+½+-+-¦p++¦÷¦÷¦-ú+ú¼-¦°-«¦+¦«¦-+¡--+++Ñúí+¦
>
> i want to clean this table by deleting records that have these types of
> characters- does this have something to do with unicode format?
>
> tia

AddThis Social Bookmark Button