Results 1 to 2 of 2

Thread: Setting Precision in SQL Query

  1. #1
    Join Date
    Feb 2003
    Posts
    23

    Setting Precision in SQL Query

    I have a calculated field in a SQL query that sometimes ends up in running decimal fields for more than 15 decimal places. I want to evenly truncate it to 6 decimal places for all records. Please let me know the command in SQL to do so.

    Thanks

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    If it is SQL Server you can use CAST or CONVERT functions

    select CONVERT(decimal(25,6),yourvariable)
    from yourtable

    or

    select CAST(yourvariable as decimal(25,6))
    from yourtable

Posting Permissions

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