numeric of variable size | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

numeric of variable size

hi<br /><br />in oracle i can have a field number(<img src=’/community/emoticons/emotion-11.gif’ alt=’8)’ />, which indicates that the number can be 8 digits or less. <br /><br />is there a similar datatype in sql server2005 also ?<br /><br />or should i create a check constraint together with the table. <br /><br />(i’ve looked in the BOL, but don’t find anything)
From Books Online …
quote:decimal and numeric
Numeric data types with fixed precision and scale. decimal[(p[, s])] and numeric[(p[, s])] Fixed precision and scale numbers. When maximum precision is used, valid values are from – 10^38 +1 through 10^38 – 1. The SQL-92 synonyms for decimal are dec and dec(p, s). p (precision) Specifies the maximum total number of decimal digits that can be stored, both to the left and to the right of the decimal point. The precision must be a value from 1 through the maximum precision. The maximum precision is 38. s (scale) Specifies the maximum number of decimal digits that can be stored to the right of the decimal point. Scale must be a value from 0 through p. The default scale is 0; therefore, 0 <= s <= p. Maximum storage sizes vary, based on the precision.

What kind of data you want to store? Integer or fractional ? In SQL Server, the size of numeric (integer data) data is not decided based on number of digits but in terms of bytes it will take to store the data. Harsh Athalye
India.
"Nothing is Impossible"
Harsh, nice to see you here thought not much active [<img src=’/community/emoticons/emotion-5.gif’ alt=’;)‘ />]<br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail
You need SQL Server 2005 Enterprise Edition with SP 2 to take advantage of the new VARDECIMAL storage format:
http://msdn2.microsoft.com/en-us/library/bb326755.aspx
Frank Kalis
Moderator
Microsoft SQL Server MVP
Webmaster:http://www.insidesql.de
]]>