Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
Why does SSMS round results?

I have a table with field Latitude of real datatype.

When I query it from SQL Server Management Studio, I get the following:

select Latitude from Location where ID = 123

enter image description here

As you can see a value of 26.09418 is returned. However, if I write a simple console in .NET and retrieve the data from the database, it returns 26.094183. It brings back an additional significant number.

Why the mismatch? Is there a way to stop SSMS from doing it?

For reference, here is the c# code to retrieve the data (using Dapper):

string sql = "select Latitude from Location where ID = 123";

using (var connection = new SqlConnection(conn)) {
    var location = connection.QueryFirst<Location>(sql);
    Console.WriteLine(location.Latitude);
}

class Location { public Single Latitude { get; set; } }
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

It would be better to store your data either with the precise decimal data type for a known scale and precision, or use float.

Saying that, you can workaround it and get your desired output in SSMS simply using str

create table t(x real)
insert into t values(26.094183)

select * from t

26.09418

select Str(x,9,6) from t

26.094183

over 4 years ago · Santiago Trujillo Report

0

The REAL type is treated as a FLOAT(24).

The FLOAT(24) datatype, or smaller, reacts the same way. The first thing to remember when experimenting with floating point numbers in SQL Server is that SSMS renders a floating point number in a way that disguises small differences

Found in red-gate.com - Calculations using the REAL datatype (single precision)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!