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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select only numeric data from a varchar field type

Status
Not open for further replies.

sinCity99

Programmer
Jan 21, 2009
20
US
Hi,

How can I only select numeric data from a varchar field that consists of both numeric and string data?

Example:

Column Name contains the following data:

23546
16565
43546
Jeff
John
Jack

How can I only display the following, is there a function in sql server that does that?
23546
16565
43546
 
Look out though isnumeric will pick out some things that don't look numeric to most people. The best solution is to stop storing things you want to use as numbers in a field designed for string data. If some of the stuff is genuinely a number and some isn't it is likely they are things that should be stored in two fields.

"NOTHING is more important in a database than integrity." ESquared
 
Thanks for the link, i'll try that. I did think about isnumeric() but wasn't sure if that was what i needed..unfortunately i can't change the database architecture :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top