Solved

length in decimal

Posted on 2010-09-10
11
509 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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 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:
Scott Pletcher 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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

832 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