Computing.Net > Forums > Programming > SQL string to integer conversion

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

SQL string to integer conversion

Reply to Message Icon

Name: Quimbly
Date: October 8, 2004 at 16:12:50 Pacific
OS: XP
CPU/Ram: irrelevant
Comment:

Hello,

I'm no expert when it comes to SQL, so go easy on me. I'm a novice.

Here's the situation: My VB6 code is constructing an SQL query string which will eventually be passed to my Access DB. There is a field in the DB which is text, but which also contains numeric values. Here are some examples of data strings that might be in this field:

0
5
11
X
N/A


I want to be able to search the purely numeric values in this field using logical numeric operators ( i.e. <, <=, >, >=, and = ), but I don't want other non-purely-numeric values returned.

So, if my query was something like

blah blah blah WHERE fieldA > 3

it would return the record with the 5 in fieldA, and none of the others from the above group, in the result set.

How do I do it?!

Any help is much appeciated.



Sponsored Link
Ads by Google

Response Number 1
Name: Quimbly
Date: October 8, 2004 at 16:14:12 Pacific
Reply:

Oops. I would want that query to return 11 as well. The problem is that as a string, the 11 isn't returned, since alphabetically, it's lower than 5.


0

Response Number 2
Name: kaepeekay
Date: October 8, 2004 at 22:00:06 Pacific
Reply:

You can use the following query

select * from t1 where val(id)>3 and isnumeric(id)=true

Val-converts them to numerics. Numeric is used to check for purely numerics.

For Eg.5,11,15adfb

It will return only 5 & 11.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: SQL string to integer conversion

String to Integer in Visual Basic www.computing.net/answers/programming/string-to-integer-in-visual-basic/5960.html

String to Integer?? www.computing.net/answers/programming/string-to-integer/11545.html

string to integer www.computing.net/answers/programming/string-to-integer/3830.html