Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find numbers containing only digits?

Status
Not open for further replies.

Cornelius19

Technical User
Mar 9, 2007
26
Hello,

I would like to find all the records that contain only digits. So far, I have this:

Code:
SELECT     *
FROM         tmp1
WHERE     (word LIKE N'[0-9]')

It returns only ten results, each containing a single digit. What I need is to find all the records containing only digits, like '378', '2005', etc. but not records containing both digits and other stuff (e.g. letters) like 'I95' or 'P2P'.

Any idea?

Cornelius
 
Actually, I meant how to find *numbers* i.e. *records containing only digits*.

Sorry for the confusion.
 
Use the ISNUMERIC function.

Code:
select *
from Table
where ISNUMERIC(word) = 1

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

My Blog
 
Take a look at these FAQ's as well:

faq183-6423

[small]----signature below----[/small]
Majority rule don't work in mental institutions

My Crummy Web Page
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top