Solved

SQL - convert txt to int and calculate (where some values are null)

Posted on 2014-07-17
2
149 Views
Last Modified: 2014-07-17
I've some numbers stored as txt and need to handle nulls while also doing a calculation.

AND CAST(ISNULL(MED_PVAR1_DPD,'0') AS INT) < 3.05

despite my thinking this might work the above gives me :
"Conversion failed when converting the varchar value '3.05' to data type int."
0
Comment
Question by:ghettocounselor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 500 total points
ID: 40203166
My quick guess would be that casting a varchar that contains a decimal point to an integer is not allowed. Have you tried casting it to a decimal?
0
 

Author Closing Comment

by:ghettocounselor
ID: 40203332
AND CAST(ISNULL(MED_PVAR1_DPD,'0') AS DECIMAL) < 3.05

THIS WORKED !
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question