473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Determine the byte size of a particular row?

Logan1337
Hi, I'm wondering if anyone knows how to determine the physical size of a particular row in a table. I suppose I could figure this out manually by determining the length of all fields, but was wondering if there's a built-in way to do this.

I'm actually using SQL Server Compact, but am interested in whether it's possible on any platform.

Thanks.

P.S.
I realize there are additional things like index entries that take up space as well. Ideally, I would like to figure out how much space could be reclaimed if a particular row were to be deleted... for capacity management.
Jul 31 '08 #1
4 2938
ck9663
2,878 Expert 2GB
I know there's a posting of similar question before. You might want to search that. I can't find my previous reference.

Or you can try this:

Expand|Select|Wrap|Line Numbers
  1. select sum(length)
  2. from syscolumns
  3. where id = object_id('MyTable')
-- CK
Aug 1 '08 #2
It appears this method only returns the maximum size of a column, not how much space a particular row is actually using in that column... unless I'm way off and unused space in a varchar is actually wasted.

Is that the case? If I have a nvarchar(4000) column, and store a string of 10 characters, will there be 3990 bytes wasted in the database file for that row? I was kind of under the assumption that things would be a little more optimized.
Aug 5 '08 #3
ck9663
2,878 Expert 2GB
No. Then you have to run through each record and each field since each one varies. And also be careful with CHAR vs VARCHAR and numeric field types.

-- CK
Aug 5 '08 #4
Ok thanks, I didn't think so but was worried there for a moment.

I think I've decided the best bet is to just store a "size" column in my table(s) and compute the length of the data in code before I insert/update the row. This will give me a rough idea of how much space a given row will use, at least compared to other rows.
Aug 6 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
235
by: napi | last post by:
I think you would agree with me that a C compiler that directly produces Java Byte Code to be run on any JVM is something that is missing to software programmers so far. With such a tool one could...
31
by: bilbothebagginsbab5 AT freenet DOT de | last post by:
Hello, hello. So. I've read what I could find on google(groups) for this, also the faq of comp.lang.c. But still I do not understand why there is not standard method to "(...) query the...
9
by: Adam | last post by:
Can someone please help!! I am trying to figure out what a font is? Assume I am working with a fixed font say Courier 10 point font Question 1: What does this mean 10 point font Question 2:...
7
by: War Eagle | last post by:
I have two byte arrays and a char (the letter S) I was to concatenate to one byte array. Here is what code I have. I basically want to send this in a one buffer (byte array?) through a socket. ...
0
by: Terry Olsen | last post by:
Using #ZipLib, I'm zipping up large files (100MB & >). I'm using a byte array to read in the file and write out to the zip file. The bigger the chunks I can read in the faster the zipping goes. ...
7
by: Doru Roman | last post by:
Hi, What is the fastest way to evaluate manually the result in this case: int a, b, c; a = 255; b = 122; c = a & b; The only way I know is transforming each number into the binary value...
2
by: Ole | last post by:
By converting a string in a textbox to a byte array I'll need the byte size of the string - how to determine that? Thanks Ole
3
by: =?Utf-8?B?SXpvcmljaA==?= | last post by:
I observed that WCF client running inside Full Trust mode XBAP application can't read byte array over 16384. If return result is bigger than that size, then client simply get null or Nothing in VB...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.