Solved

Defragment a database - how?

Posted on 2014-03-05
3
332 Views
Last Modified: 2014-03-07
The backbone of my database (SQL 2008 Express) is a table that stores photographs in a filestream column. This table accounts for practically all the data in the db, the other tables containing just a few hundred rows of reference data. I created this table and its primary key on a filestream filegroup.

At the outset, I set the database up with a primary filegroup, a secondary one (default for user data) and a filestream filegroup. For a couple of months now I've been repeatedly deleting and repopulating this main table.  Along the way I've encountered quite a bit of unreliability with the filestream technology - sometimes when repopulating the table the db would randomly ignore the filestream group and start saving the data to the secondary filegroup. When this happened the db ran out of space and the process stalled. In this event my solution has always been to drop and recreate the table.

Now my secondary file is over 4GB, its log file is 1.4GB, and I'm out of space unable to run anything.

How do I clean this up?
0
Comment
Question by:TimHudspith
3 Comments
 
LVL 42

Assisted Solution

by:EugeneZ
EugeneZ earned 250 total points
Comment Utility
try to start from db reindex\update stats \dbcc checkdb

please clarify "db ran out of space "? is trn log going out of free space? if yes - let DB in the Simple Recovery
---
also you said that you are using SQL 2008 Express that has Database Size Limit 4GB

try SQL Server 2008 R2 Express where Database Size Limit Increased to 10GB
or free sql express 2012 http://www.microsoft.com/en-us/sqlserver/editions/2012-editions/express.aspx
0
 
LVL 39

Accepted Solution

by:
lcohan earned 250 total points
Comment Utility
"Now my secondary file is over 4GB, its log file is 1.4GB, and I'm out of space unable to run anything.

How do I clean this up? "


If is true that you ran everything on SQL 2008 Express then your MAX database size is indeed 4GB therefore

option 1 is to upgrade (maybe even developer edition is good enough for you yet still free)

OR

option 2 you must copy then delete (move) old useless data from the active table. You can create a new for instance call it PhotoArchive database where you put identical table and move old data from active used database table(the big one...).

http://msdn.microsoft.com/en-us/library/cc645993(v=sql.100).ASPX
0
 

Author Comment

by:TimHudspith
Comment Utility
Thanks for the suggestions but in the end I ran Ola Hallengren's SQL Server Maintenance Solution to clean up my indexes, then ran the shrinkdatabase command, which did the trick.

http://ola.hallengren.com/

DBCC SHRINKDATABASE
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
separate column 24 19
SQL Server memory Issue 7 73
MSSQL Frequency of Years From Days Field 2 10
Azure SQL DB? 3 11
Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
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…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

762 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

13 Experts available now in Live!

Get 1:1 Help Now