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)
 Find All Numbers in a character field

Author  Topic 

miichelle.j.tyler
Starting Member

1 Post

Posted - 2006-05-15 : 16:32:24
I need to identify rows where the 32-character ID field is all numeric. Is that possible using an SQL select statement? Other than the obvious method of searching for the index value of 0-9 for each character in the string... query is too long.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-05-15 : 16:49:11
use IsNumeric(column) function
or
column not like '%[0-9]%'

Go with the flow & have fun! Else fight the flow
Blog thingie: [URL="http://weblogs.sqlteam.com/mladenp"]
Go to Top of Page

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2006-05-16 : 06:33:25
Hi all,

As usual, beware of the issues of IsNumeric...
http://aspfaq.com/show.asp?id=2390

It sounds like spirit1's other suggestion (with a minor typo modification) will do the trick for you in this case, though...

declare @t table (v varchar(10))
insert @t
select 'abc'
union all select '23214'
union all select '23abc214'
union all select '232.14'

select * from @t where v not like '%[^0-9]%'




Ryan Randall
www.monsoonmalabar.com London-based IT consultancy

Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-17 : 06:11:05
Also refer
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=56713

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -