Geekzone: technology news, blogs, forums
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.

104 posts

Master Geek
+1 received by user: 5

Topic # 136237 20-Nov-2013 08:40 Send private message


Have a client whose SQL Server 2008 (Express) DB is very close to the 10GB hard limit.  Upgrading to Full SQL Server is not an option.

I have told them we need to remove some data, and that it is likely that the photos that are stored with each contact are the issue. However they refuse to remove data unless I can prove that will resolve the issue (and even then I am not sure if they will do it)

I have confirmed with SSMS that the table containing the photos is 9.8GB but as it also holds all the other relevant contact data I can't prove it is the photos.

This is a commercial program so I can't alter any of the DB tables etc.

Is there an SQL command I can use to show the total size (MB,GB) of all the data stored in a column in a table so I can prove it is the photos?


Create new topic

This is a filtered page: currently showing replies marked as answers. Click here to see full discussion.

1169 posts

Uber Geek
+1 received by user: 298


  Reply # 937697 20-Nov-2013 08:46 Send private message

select sum(datalength(column)) from table

Windows 7 x64 // i5-3570K // 16GB DDR3-1600 // GTX660Ti 2GB // Samsung 830 120GB SSD // OCZ Agility4 120GB SSD // Asus PB278Q @ 2560x1440
Samsung Galaxy S4 GT-I9505 w/Telecom

670 posts

Ultimate Geek
+1 received by user: 43

  Reply # 937803 20-Nov-2013 11:32 Send private message

Its not really a simple answer.

SQL Server stores data in 8K data pages, there are 8 pages to an extent (64kb) and 16 extents to a megabyte. A row in a page cannot be bigger than the page. There are three types of allocation unit, IN_ROW_DATA (normal stuff), LOB_DATA (your images, text etc,) and your ROW_OVERFLOW_DATA (varchar, varbinary etc.). If the data in a column in a data row (IN_ROW_DATA) contains more than 8K it will be moved to the ROW_OVERFLOW_DATA allocation unit. LOB data such as your images is ok.

To get the size of the database on disk SELECT used_page_count /128.0 FROM sys.dm_db_partition_stats will give you the size in megabytes.

To determine the allocation units and sizes used in each,

SELECT, alloc.type_desc, alloc.total_pages, alloc.used_pages, alloc.data_pages
FROM sys.allocation_units as alloc
JOIN sys.partitions as part on alloc.containter_id = part.partition_id
JOIN sys.objects as obj ON part.object_id = obj.object_id
WHERE = 'mytable'

This will give you the number of pages used in the LOB_DATA allocation unit which you can use to calculate the size on disk. It will also allow you to see the size of any large data fields you have that are moved to the ROW_OVERFLOW_DATA allocation unit.

Hope that provides some useful information regarding the issue.


Create new topic

Twitter »
Follow us to receive Twitter updates when new discussions are posted in our forums:

Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:

Follow us to receive Twitter updates when new jobs are posted to our jobs board:

Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:

News »

Trending now »
Hot discussions in our forums right now:

Forms of government for New Zealand
Created by charsleysa, last reply by Kyanar on 18-Apr-2014 20:55 (98 replies)
Pages... 5 6 7

MH370 - Call for Search & Rescue Help
Created by DS248, last reply by Sideface on 17-Apr-2014 17:28 (735 replies)
Pages... 47 48 49

galaxy s4 now on 4.4.2
Created by nzrock, last reply by Cameron1991 on 19-Apr-2014 01:35 (51 replies)
Pages... 2 3 4

why does the tax payer have to pay for the prince and princess' 6 star holiday?
Created by joker97, last reply by Geektastic on 17-Apr-2014 15:49 (67 replies)
Pages... 3 4 5

Snap suffering Trans-Tasman congestion 18/04?
Created by Lias, last reply by NonprayingMantis on 19-Apr-2014 00:05 (26 replies)
Pages... 2

Help ! Home business connection and VDSL dead. yikes.
Created by Scotsman, last reply by Scotsman on 17-Apr-2014 21:10 (26 replies)
Pages... 2

Free connection to Ultra Fibre not true
Created by kapitikarl, last reply by cbrpilot on 15-Apr-2014 13:24 (27 replies)
Pages... 2

TVNZ on Demand Jailbreak Detection
Created by TranceManNZ, last reply by hio77 on 18-Apr-2014 20:25 (12 replies)

Geekzone Live »
Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.

Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.