Solved

length in decimal

Posted on 2010-09-10
11
508 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
11 Comments
 
LVL 3

Assisted Solution

by:ghayasurrehman
ghayasurrehman earned 40 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 40 total points
ID: 33649445
Its 12..

use the below to determine the size
select LEN(642418216.00)
0
 
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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
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 40 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:
ScottPletcher earned 167 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 22

Assisted Solution

by:Snarf0001
Snarf0001 earned 160 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 53 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now