August 1, 2008 at 6:33 am
I am confused about something when it comes to the decimal data type. Is the decimal point considered part of the precision? In other words how is 12345.67 defined? I have been told as decimal(8,3), decimal(8,2), decimal(7,3) and decimal(7,2).
My guess would be decimal(8,2). I was hoping that I could get this cleared up once an for all.
Thanks
August 1, 2008 at 7:19 am
meichner (8/1/2008)
I am confused about something when it comes to the decimal data type. Is the decimal point considered part of the precision? In other words how is 12345.67 defined? I have been told as decimal(8,3), decimal(8,2), decimal(7,3) and decimal(7,2).My guess would be decimal(8,2). I was hoping that I could get this cleared up once an for all.
Thanks
BOL (Books Online) is your friend...
http://msdn.microsoft.com/en-us/library/aa258832(SQL.80).aspx
So: 12345.67 is decimal(7,2) 🙂
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
August 1, 2008 at 7:21 am
Or rather - that's the minimum decimal size which could hold it.
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
August 1, 2008 at 8:16 am
Thanks for the information and the link. I had an instructor which told us that the decimal point was part of the precision and another instructor who said it wasn't. I checked the net and was unable to find a definitive answer.
Thanks again.
August 1, 2008 at 8:54 pm
Simple test proves it...
SELECT 1, CAST(1.23 AS DECIMAL(5,2))
SELECT 2, CAST(12.34 AS DECIMAL(5,2))
SELECT 3, CAST(123.45 AS DECIMAL(5,2))
SELECT 4, CAST(1234.56 AS DECIMAL(5,2))
--Jeff Moden
Change is inevitable... Change for the better is not.
August 4, 2008 at 10:44 am
Thanks. I appreciate the help.
August 4, 2008 at 7:42 pm
You bet. Thank you for the feedback.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply