views:

262

answers:

4

I have the following problem. We have a database that stores binaries in the database. We know the size of the database can be big so we removed all the binaries from the database and used the task "shrink" on it. This way we hoped that the database would be much smaller. These are the results:

before removal size was: 20 gigabyte after removal size was: 25 gigabyte (incl log file) after shrink size was: 13 gigabyte

now I have no idea where that 13 gig is from, the largest table in the database is a logtable and it's 1.3 gig all the rest combined doesn't take 200 mb ...

could it be that there is still some data in the logfile that the shrink task cannot remove? is there a solution for this problem?

thx.

+2  A: 

If your recovery model is "Full" and you haven't backed up and then shrunk your transaction log then it could still remain large.

Depending on your situation, one of th easiest ways of shrink the transaction log is to set your Recovery Model to simple, then shrink the transaction log files and then set recovery model back to full.. However, if this is a production system where you may need a point in time recovery then you should perform backups of your transaction log instead.

Robin Day
Detach and attach with log file delete is another option- http://bloggingabout.net/blogs/mglaser/archive/2007/01/12/sql-server-tip-shrinking-a-sql-server-log.aspx
RichardOD
thx this is it ... the recovery model was set to full indeed ... we have daily physical backups so it shouldn't be an issue.Thx pall
Sem Dendoncker
deleting the log file is seriously a bad idea! dont even think about it!
Nick Kavadias
Deleting the t-log file is terrible idea.
SQLChicken
indeed the logfile cannot be deleted btw, I tried that one before, it keeps complaining about corrupted data ...
Sem Dendoncker
+2  A: 

To get more information about space usage you can try:

EXEC sp_spaceused;
santiiiii
A: 

Please remember to set up transaction log backups (not just database backups as they will not keep the log small as you have found out) after you take Robin Day's advice and shrink the log or your log will just grow large again. Our transaction logs are backed up every 15 minutes. Your schedule may need to be more or less frequent depending on how much data you can afford to lose if you have a failure. At a minimum I'd do a daily log backup just to keep the log a reasonable size.

HLGEM
we have daily backups, it enough for our applications.
Sem Dendoncker
daily backups of the database do not affect the logs, you must also back up the log.
HLGEM
A: 

One possibility is that the table you've deleted the data from is a Heap (means there is no clustered index), and when you delete from a heap the space allocated for the table won't necessarily be freed. Check this article from MS: http://support.microsoft.com/kb/913399

onupdatecascade