March 25, 2009 at 5:20 am
can we have a function to identify the special characters in a table?
March 25, 2009 at 7:55 am
March 25, 2009 at 8:06 am
of course...but it depends on what are "special characters" for you;
do you mean where any character is not alphanumeric(or space) like this?
select * from gmact where actname like '%[^a-z,A-Z,0-9 ]%'
or are you looking for hi ascii codes? what is it specifically?
Lowell
March 25, 2009 at 8:11 am
sure, but what is "special characters" for you?
anything not a space and alphanumeric, for example? or are you after specific chars, like hi ascii characters?
here's a simple example
select * from YOURTABLE where SOMECOLUMN like '%[^a-z,A-Z,0-9 ]%'
Lowell
March 26, 2009 at 1:54 pm
If it does not need to be a function per se, then why reinvent the wheel ...
sp_validname
http://msdn.microsoft.com/en-us/library/ms189525.aspx
RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."
March 27, 2009 at 5:36 pm
I am struggling with same issue. I want to identify special characters at varchar column so that I can replace it with some other character.
Example: “Hello World”
Space between “Hello” and “World” is some special character; I want to know what that character is so that I can replace it with some other character.
Like:
UPDATE dbTABLE set tblColA=rtrim(ltrim(REPLACE(tblColA,char(10),'XX'))) where (tblColA like '%' + char(10) + '%')
Thank You
March 27, 2009 at 9:57 pm
Hi Singh,
You need to update the space to ‘XX’
Then
UPDATE dbTABLE
set tblColA= ‘XX’
where tblColA like ' ' –space(not a singe code,with one space)
ARUN SAS
March 28, 2009 at 6:17 pm
SinghS (3/27/2009)
I am struggling with same issue. I want to identify special characters at varchar column so that I can replace it with some other character.Example: “Hello World”
Space between “Hello” and “World” is some special character; I want to know what that character is so that I can replace it with some other character.
Like:
UPDATE dbTABLE set tblColA=rtrim(ltrim(REPLACE(tblColA,char(10),'XX'))) where (tblColA like '%' + char(10) + '%')
Thank You
I suspect that you mean you want to find and replace more than just one special character at a time. There're lots of ways to do it but, to determine the best way for your situation, you need to help us help you. We need the Create statement for a test table and some "readily consumable" test data. Please see the link in my signature below for what I mean by all of that.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 12, 2012 at 10:20 am
I know this was posted ages ago, but I just came across a scenario that requires me to replace such values and I would like to be able to do it using a single update statement such as:
update TABLE
set FIELD = Replace(FIELD,,'%[^a-z,A-Z,0-9 ]%','')
I'm trying to remove all those characters from my column values. How can I do this?
Regards,
John
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply