RSS Forums RSS
Please support our MS SQL advertiser: Programming Forums
Views: 4993 | Replies: 4
Reply
Join Date: Apr 2006
Posts: 2
Reputation: Questor is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Questor Questor is offline Offline
Newbie Poster

WHERE field *has a numeric value?*

  #1  
Apr 17th, 2006
The table I'm searching is varchar. The entries I'm interested in are only numeric. But for some reason there's mixed string/int entries. How can I chose only the numeric values?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2005
Location: Manchester, UK
Posts: 482
Reputation: pty is on a distinguished road 
Rep Power: 4
Solved Threads: 34
pty's Avatar
pty pty is offline Offline
Posting Pro in Training

Re: WHERE field *has a numeric value?*

  #2  
Apr 17th, 2006
i dont use SQL Server much these days, but is there not a isNumber() or isNumeric() function?

If there isn't im sure writing your own wouldnt be that difficult. Just attempt to cast a varchar as a number and if it succeeds its a number. If it doesnt, it aint.

The 'real' solution to this is to fix your database so that text data is stored in char/varchar fields and numeric data is stored in the appropriate numeric type.
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 482
Reputation: campkev is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: WHERE field *has a numeric value?*

  #3  
Apr 17th, 2006
pty is right. this should do it for you
 select * from tablename where isnumeric(columnname) = 1
Reply With Quote  
Join Date: Apr 2006
Posts: 2
Reputation: Questor is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Questor Questor is offline Offline
Newbie Poster

Re: WHERE field *has a numeric value?*

  #4  
Apr 18th, 2006
That worked, thank you!
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 482
Reputation: campkev is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: WHERE field *has a numeric value?*

  #5  
Apr 18th, 2006
de nada
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:23 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC