Skip to main content
Inspiring
March 25, 2009
Question

SQL Server Question

  • March 25, 2009
  • 2 replies
  • 358 views
I have a table in sql server. One column is quantity, datatype int and the other is price, datatype decimal. For cfinput, both are text and I predisplay 0.00 to let the user know the format.

What is happening now is that users are entered 1.5, etc., into the quantity field and the insert blows up because of the datatype. So I changed the quantityt datatype from int to decimal so it will accept 1.5. However, when I look in the table, the value is stored as 2 (it will round up or down) instead of 1.5. and displays as 2. The price works and looks fine, but the quanity does not work.

What do I need to do to retain the decimal, and what affect will that have on existing data that was previously int ?
    This topic has been closed for replies.

    2 replies

    Inspiring
    March 25, 2009
    Forgetting data and code for a second, do your business rules allow you to have quantities that are not integers?
    Inspiring
    March 25, 2009
    > What is happening now is that users are entered 1.5, etc., into the quantity
    > field and the insert blows up because of the datatype. So I changed the
    > quantityt datatype from int to decimal so it will accept 1.5. However, when I
    > look in the table, the value is stored as 2 (it will round up or down) instead
    > of 1.5. and displays as 2. The price works and looks fine, but the quanity does
    > not work.
    >
    > What do I need to do to retain the decimal, and what affect will that have on
    > existing data that was previously int ?

    Are you sure you're not munging the datatype during the insert? For
    example, by using a cf_sql_integer datatype on a cfqueryparam on the
    insert? Try inserting some data directly and see if it maintains the
    decimal values.

    --
    Daniel Short
    Site Drive, Inc. ( http://www.sitedriveinc.com)
    Adobe Community Expert