Results 1 to 2 of 2

Thread: Set the number of decimals via SQL

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    78

    Question Set the number of decimals via SQL

    Good afternoon one and all!!

    VB 6
    Access database

    I am using SQL statements to modify a database. I have a table that I have added a field to and set the field to "double" (which matches my other numeric fields in the db). This works fine and I am running a calculation on two other fields to get the value to this field. This also is working fine....

    The trouble is I would like only 2 decimal places and can't seem to figure out how to do this via SQL.

    Here is the statement I'm using to add the column:

    sql = "ALTER TABLE " &NewSurvey &"_CR ADD COLUMN Bar_Value DOUBLE"

    Then I run an UPDATE query to do the calculation and populate the field. It of course is carrying out the calculation to the nth decimal and I don't need that. I would rather "weed" it out with a format option than deal with the extra "stuff" later!!!!

    Any suggestions would be greatly appreciated!

    Thanks,
    Mary

  2. #2
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    When you do the update, do

    UPDATE tablename SET somefield = ROUND(thevalue, 2)
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width