Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 identify char

Author  Topic 

fmardani
Constraint Violating Yak Guru

433 Posts

Posted - 2005-07-14 : 05:35:43
Hi,
How do you identify if a character (other than a number) is present in the field?
Thanks

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2005-07-14 : 06:03:11
If you replace all number characters with 'empty strings' and the length of the amended string is > 0....then you've got a non-number character in it
Go to Top of Page

mmarovic
Aged Yak Warrior

518 Posts

Posted - 2005-07-14 : 06:58:44
IsNumeric(replace(field, ' ', '')) = 0?
Go to Top of Page

fmardani
Constraint Violating Yak Guru

433 Posts

Posted - 2005-07-14 : 07:07:01
Hi,
I don't think I should be doing this because the field is holding phone numbers. some of these values have a bracket or a +
So I just want to select those records with their values...
Thanks
Go to Top of Page

mmarovic
Aged Yak Warrior

518 Posts

Posted - 2005-07-14 : 07:12:31
ok, then replace these characters too or use Andrew's solution.
Go to Top of Page

fmardani
Constraint Violating Yak Guru

433 Posts

Posted - 2005-07-14 : 07:47:14
Great.
Thank you all.
Go to Top of Page

fmardani
Constraint Violating Yak Guru

433 Posts

Posted - 2005-07-14 : 07:50:38
quote:
Originally posted by AndrewMurphy

If you replace all number characters with 'empty strings' and the length of the amended string is > 0....then you've got a non-number character in it



How do I replace all number characters
I don't think I should just use
replace(field, 0, '')
replace(field, 1, '')
replace(field, 2, '')
replace(field, 3, '')
replace(field, 4, '')
.
.
.
Go to Top of Page

mmarovic
Aged Yak Warrior

518 Posts

Posted - 2005-07-14 : 08:03:14
e.g. isNumeric(replace(replace(field, ' ', ''), '-', '')) = 0
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2005-07-14 : 08:29:55
-- Rows with a nonnumeric character
SELECT <col> FROM <tbl>
WHERE PATINDEX('%[^0-9]%',<col>) > 0

rockmoose
Go to Top of Page
   

- Advertisement -