WHERE field *has a numeric value?*

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2006
Posts: 2
Reputation: Questor is an unknown quantity at this point 
Solved Threads: 0
Questor Questor is offline Offline
Newbie Poster

WHERE field *has a numeric value?*

 
0
  #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?
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 523
Reputation: pty is on a distinguished road 
Solved Threads: 37
pty's Avatar
pty pty is offline Offline
Posting Pro

Re: WHERE field *has a numeric value?*

 
0
  #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 Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: WHERE field *has a numeric value?*

 
0
  #3
Apr 17th, 2006
pty is right. this should do it for you
  1. SELECT * FROM tablename WHERE isnumeric(columnname) = 1
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 2
Reputation: Questor is an unknown quantity at this point 
Solved Threads: 0
Questor Questor is offline Offline
Newbie Poster

Re: WHERE field *has a numeric value?*

 
0
  #4
Apr 18th, 2006
That worked, thank you!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: WHERE field *has a numeric value?*

 
0
  #5
Apr 18th, 2006
de nada
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for MS SQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC