473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Check varchar field numeric using SQL

Hi,

How can I check if all bytes in a varchar field is all numeric using
SQL ?

-- peter

Aug 11 '06 #1
4 24401
ka******@graduate.hku.hk wrote:
Hi,

How can I check if all bytes in a varchar field is all numeric using
SQL ?
You could:
(1) use a loop and check each character manually
(note: signs and exponents for floating point numbers)
(2) try to convert the value and intercept exceptions for non-digits
(3) use regular expression matching:
http://www.ibm.com/developerworks/db...301stolze.html

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Aug 11 '06 #2

ka******@graduate.hku.hk wrote:
Hi,

How can I check if all bytes in a varchar field is all numeric using
SQL ?

-- peter
WHERE TRANSLATE(<field>, '', '1234567890') = '' AND <field<''

B.

Aug 11 '06 #3

WHERE TRANSLATE(<field>, '*', ' 1234567890') = ''
If there is a possibility of "length(<field>) = 0", you had better to
use Brian's way.

Aug 12 '06 #4

Tonkuma wrote:
WHERE TRANSLATE(<field>, '*', ' 1234567890') = ''
If there is a possibility of "length(<field>) = 0", you had better to
use Brian's way.
Thanx Tonkuma.

When i replied before i was thinking "How would Tonkuma do it?".

In my mind, TRANSLATE is your function. :)

B.

Aug 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Niall Porter | last post by:
Right this has to be a Micro$oft mess-up surely...? I'm running SQL 2k standard with SP3. I have a table which I'm trying to query using a LIKE operator on a varchar field as follows .......
1
by: luna | last post by:
got so far then it broke and i cant get it working again - it was updating fine but not inserting and now im getting a "Error converting data type varchar to numeric" which i didnt have before.......
13
by: Vivek | last post by:
Hi, Is it possible to insert a '\0' value or for that matter any control character into a DB2 CHAR/VARCHAR field ? So if i do a 'select hex(column) from table' i should see a 0 in the output....
0
by: jjtechy | last post by:
The data like 0.06234 that is imported from another server is getting changed as 6.234....E-2 in my local.it is looking as 0.06234 in that server.The datatype of that column is varchar(50) in both...
0
by: Larrys | last post by:
I am fetching a VARCHAR field in a cursor. The VARCHAR field ins defined as 'not null with default'. When I am fetching a row where the VARCHAR field does not have a value, the value of the working...
1
Shashi Sadasivan
by: Shashi Sadasivan | last post by:
Hi, Due to a certain circumstance i have to add a field to my table, which would be a varchar type. this varchar contructs istfel using 4 fields of type bit so if the table def goes as isA(bit),...
5
by: ITCraze | last post by:
Please Guys help me out , as I need the solution of this problem very fast.Please help me. My table contains a varchar field which contains time like : 04:09PM Now the problem is that I have...
3
by: lornab | last post by:
Hi I wonder if anyone can help - I think the answer is simple but it's been a really long day and I need to get this done!! My select statement goes like this... SELECT client, ...
5
AAPWM
by: AAPWM | last post by:
Hello My job is to extract data from my companies database with Crystal Reports, export that data to Excel, modify the data, save the data as "Text "tab delimited"", and upload to the database...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.