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 determine if a field contains text characters or numbers

Status
Not open for further replies.

eyorre

Programmer
Jan 24, 2002
32
GB
I have a SQL table with a field type set as varchar. Obviously this field can therefore contain either text or numbers. When retrieving data from the table I need to be able to determine if all the filtered results are numeric or whether there are alpha characters included too. I need to do this so that when a sort is carried out on the results it will sort in an appropriate way e.g. if the results are numeric the sort should result in 1,4,17 rather than 1,17,4.

If the results are numeric I can then use:
Convert(int,tblEntryValue.EntryValue)
ORDER BY tblEntryValue.EntryValue

How can I determine what data types are in my filtered record set?
 
Have you tried IsNumeric?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top