?
Solved

length in decimal

Posted on 2010-09-10
11
Medium Priority
?
520 Views
Last Modified: 2012-05-10
does it include the period (.) also?

642418216.00
is this 11 or 12 bytes?

thanks
0
Comment
Question by:anushahanna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 3

Assisted Solution

by:ghayasurrehman
ghayasurrehman earned 160 total points
ID: 33649403
12 bytes
0
 
LVL 6

Author Comment

by:anushahanna
ID: 33649422
so, dot is always included?
0
 
LVL 16

Assisted Solution

by:vdr1620
vdr1620 earned 160 total points
ID: 33649445
Its 12..

use the below to determine the size
select LEN(642418216.00)
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 15

Expert Comment

by:gplana
ID: 33649606
But understand that decimal is a variable-length datatype. So this number is 12 byte width, but other number could be less or more bytes, depending on the number of digits.

See this link for more information: http://msdn.microsoft.com/en-us/library/ms190476.aspx
0
 
LVL 6

Author Comment

by:anushahanna
ID: 33649687
OK.

>>this number is 12 byte width, but other number could be less

you  mean 6424.26 is 6 bytes and 11.1 is 3 bytes, right?
0
 
LVL 6

Author Comment

by:anushahanna
ID: 33649696
in the link you provided
http://msdn.microsoft.com/en-us/library/ms190476.aspx

it says int is 4 bytes only - is it because it lacks the decimal point and hence less storage used, as compared to the decimal?

thanks
0
 
LVL 15

Assisted Solution

by:gplana
gplana earned 160 total points
ID: 33649868
int last 4 bytes because uses binary encoding, and uses the int as is encoded on the machine. You can represent any integer nmber from -2^31 to +2^31-1. So in total they are 2^32 which are the possible combinations on a 32 bits integer (i.e. 4 bytes).
Decimal packs decimal digits. On this encoding you need 4 bits for every digit, so you can represent 2 digits on a byte.This is the theory, but you need some extra bytes to know how long is the data, as it's a variable width datatype
Hope it helps.
0
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 668 total points
ID: 33650876
For decimal columns, the physical storage is based on the *total* digits (precision):

Precision Storage bytes
1 - 9         5
10-19       9
20-28     13
29-38     17

So, decimal(9, <whatever>) takes 5 bytes, decimal(10, <whatever>) takes 9 bytes, etc..

The decimal point is not stored per se.  Decimals are stored in an internal format -- you don't really have to worry abou the details of that.
0
 
LVL 23

Assisted Solution

by:Snarf0001
Snarf0001 earned 640 total points
ID: 33650942
Scott is completely correct, the number you indicated takes 9 bytes to store, not 11 or 12.

>> select LEN(642418216.00)

will NOT return the actual data storage length, it returns the number of characters.
To return the actual storage size, use DATALENGTH()

select DATALENGTH(642418216.00)
0
 
LVL 4

Assisted Solution

by:parthmalhan
parthmalhan earned 212 total points
ID: 33652333
Decimal is not included

if the datatype of a field is numeric(5,2)
then
its can contain atmost (999.99) value

Decimal point s not included in numeric

But if you are using varchar(5)
then decimal is also counted
so value may 33333
or 333.3
or 99.99 etc
0
 
LVL 6

Author Comment

by:anushahanna
ID: 33661737
Thanks for correcting that. helped.
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question