January 9, 2009 at 3:52 pm
When doing math with sql server, why doesn't it default to return real numbers?
select 2621475 / 65535
returns 40
How do you get the remainder?
January 9, 2009 at 4:19 pm
If you mean a true remainder, this will give it:
select 2621475%65535
If you actually mean you want to see the decimal fraction, this will give it:
select 2621475./65535.
As to why, you should read about math operations in SQL Server Books Online, but the short answer is that the code you posted is integer math and so it returns an integer result. If you want a numeric or floating point result, cast the values to that before performing the math.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy