Problem checking for 0 values in decimal field in SQL

FiFi Member Posts: 7
edited 2009-06-18 in SQL General
Hi there,

I've made a change for a customer running on NAV 2009 on SQL Server 2008, to check if any lines on a Purchase Order have a unit cost of 0. If so do not allow the PO to be released.

For lines with Unit Cost of 0.21919 say, the check if unit cost = 0 is returning TRUE?? It does not happen on Native client.

Has anyone come accross this and got around it?

Thanks in advance,

Fi

Comments

  • FiFi Member Posts: 7
    Hi there,


    I've programmed around this for the moment and seems to be working ok.

    I tried using MOD function & ROUND function, to see if I could pick up decimal places somehow, but neither of these worked.

    My function does the following :-

    1. Format Unit Cost as text
    2. Determine if there is a leading 0.
    3. If Leading 0 and all characters after decimal place = 0 then unit cost is 0.

    If anyone more standard way please let me know :wink:

    Thanks,

    Fi
  • FishermanFisherman Member Posts: 456
    Odd... that looks like a type casting issue.

    Did you try comparing the value against 0.00 instead of 0?
Sign In or Register to comment.