[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 631
  • Last Modified:

SQL Server Management Studio is automatically rounding my calculation

Hi !

SQL Server Management Studio is automatically rounding my calculation done in TSQL in the result pane. How can I avoid this.

Thank You !
  • 4
1 Solution
Aaron TomoskyTechnology ConsultantCommented:
You can
Select cast(field as decimal(18,2)) from table

If you give us your query and sample data we can give more specific help.
Rubicon2009Author Commented:
SELECT (A.ActualEnd - A.ActualStart - Isnull(A.Lunch, 0)) / 60 AS 'FinalDuration'

with real values, the result will be 7 instead of 7,25
SELECT (780 - 300 - 45) / 60

FYI, values are minutes from midnight
Éric MoreauSenior .Net ConsultantCommented:
because you divide by an integer:

SELECT (780 - 300 - 45) / cast(60 as money)
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!

Rubicon2009Author Commented:
Using CAST like suggested is still giving me the wrong results, I now optain 7.00 instead of 7.25
Rubicon2009Author Commented:
(780 - 300 - 45) / 60.0
Is resulting 7.25000

Rubicon2009Author Commented:
Thank You

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now