Solved

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

Posted on 2014-07-17
2
150 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 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