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?

Recommended Answers

All 4 Replies

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.

pty is right. this should do it for you

select * from tablename where isnumeric(columnname) = 1

That worked, thank you!

de nada

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.