Will decimal(18,2) use more storage than decimal(6,2) even if the actual value is 34.25?
Will decimal(18,2) use more storage than decimal(6,2) even if the actual value is 34.25?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The storage required is defined by the precision and scale that you’ve defined in your table.
See the MSDN documentation on the
decimaltype.With
decimal(18, 2)in your case, you’ll use 9 bytes – regardless of what value is stored in that column.With
decimal(6, 2), you would be using 5 bytes.SQL Server 2008 and higher in the Enterprise (or Developer) SKU have a
vardecimalflag, too, that enables optimizing the storage of decimal values. Read more about it here at the SQL Server Storage engine team blog