Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to shrink a 171 GB size SQL 2005 database !!!

Posted on 2008-10-08
14
Medium Priority
?
1,438 Views
Last Modified: 2012-05-05
Hi All,
Few days agao I posted a similar question abpout shrinking a specific database, and the conculusion was that it cannot be shrink. This time it is a different database and the log file is big which make me thin that it can be shrink. Please read below.

I have a 171 GB database. I want to shrink this database as much as possible.

Under SQL Managment studio when I see the property of this database, the size of the database is 174335.94 MB and the space available is 4144.27 MB.

The Files for this database and have following sizes.

MDF size = 14272 KB
NDF size = 82286016 KB
LDF size = 96219712 KB

When i run sp_spaceused I get the following numbers;
DatabaseName: TestDB
DatabaseSize: 174335.94 MB
UnAllocatedSpace: 4144.27 MB
Reserved: 78056560 KB
Data: 64241760 KB
IndexSize: 13774472 KB
Unused: 40328 KB

I dont want to corrupt or lose the data.
Please suggest the best & easist way to reduce the size of this database as much as possible.

Thanks a million for your prompt help.

Zee
0
Comment
Question by:zeeshanbutt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
14 Comments
 
LVL 60

Expert Comment

by:chapmandew
ID: 22672671
0
 
LVL 41

Expert Comment

by:graye
ID: 22672835
Yes you should be able to shrink this database.  You need to perform periodic maintenance tasks to curb the growth of the logfile.    Take a look at the following article, it explains everything in pretty good detail.
http://home.hot.rr.com/graye/Articles/SQL_LogMaintenance.htm 
0
 

Author Comment

by:zeeshanbutt
ID: 22673070
Someone told me to take a fullbackup first, and then try to shrink which will reduce the log size.
Is it true?
0
Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

 
LVL 60

Expert Comment

by:chapmandew
ID: 22673079
Nope, that is 100% not true.
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 22673088
You can take a log backup and then try to shrink it though.
0
 

Author Comment

by:zeeshanbutt
ID: 22673316
The transaction log size is 91 GB. I dont want to backup transaction log since I dont have more than 65 GB of free space on the disk. But I want to truncate it, is this a good idea? How do I truncate transaction log, without hurting the database?

Please suggest.

Zee
0
 
LVL 60

Accepted Solution

by:
chapmandew earned 2000 total points
ID: 22673334
You can truncate the log...just make sure afterwards that you do a full backup and then setup a maint plan that does the log backups for you...or set your recovery mode to simple.

backup log yourdbname with truncate_only

dbcc shrinkfile('logfilename', 0)

Then you're all set.
0
 

Author Comment

by:zeeshanbutt
ID: 22673457
chapmandew,

IDo I have to run the following two commands together?

backup log yourdbname with truncate_only
dbcc shrinkfile('logfilename', 0)


0
 

Author Comment

by:zeeshanbutt
ID: 22673593
Sorry I mistype earlier.

The LDF size is 91 GB. I dont want to backup LDF since I dont have more than 65 GB of space on the disk. But I want to truncate it. How do I truncate LDF (logs), without hurting the database?

Also IDo I have to run the following two commands together?

backup log yourdbname with truncate_only
dbcc shrinkfile('logfilename', 0)

Please suggest.

Zee
0
 

Author Comment

by:zeeshanbutt
ID: 22674293

I have reduced my database size. The LDF file size is now 5000 KB that is 0.005 GB only (originaly it was 96 GB). And the database size now is 78.4GB only (originaly it was 171 GB).

This is what I did.
1. Switch to SIMPLE recovery model
2. Truncate the transaction log (BACKUP LOG dbName WITH NO_LOG)
3. Shrink it (DBCC SHRINKFILE)

Since I will be scheduling regular full backups, I will be fine using SIMPLE recovery model.

Thanks everyone for thier help.

Zee
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 22674454
I don't see how you can close this question w/o assigning points....
0
 

Author Comment

by:zeeshanbutt
ID: 22715344
WhackAMod,

I tried to assign points to chapmandew & also to myself since chapmandew was missing one key point (Switch to SIMPLE recovery model) which was a must and not an optional point. That's why I thought if I can assign 300 points to chapmandew, and 200 to myself. I wasn't sure if I could do that. And it seems like I can't. chapmandew is always very helpful and I dont mind giving him all 500 points. How can I do that now?
Please suggest.
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 22715415
Actually, switching to simple is not a must whatsoever.  :)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

705 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