Solved

bring a database size down (there is no data anymore)

Posted on 2011-03-10
12
270 Views
Last Modified: 2012-06-27
for business reasons, data from a database was totally truncated, but size was not altered. They want to just keep the schema for quick reference without data. How can I shrink the whole database size back down, since there is no more space required for data and index. So, basically, not wanting to drop the DB, but want to reclaim the space on disk, and satisfying only with the schema.

thanks
0
Comment
Question by:anushahanna
  • 5
  • 3
  • 3
  • +1
12 Comments
 
LVL 32

Accepted Solution

by:
ewangoya earned 84 total points
ID: 35101249

Do a backup of the database which should now be fast

From Management Studio, right click on database, go to Tasks->Shrink->Database

Taht should do the trick
0
 
LVL 9

Assisted Solution

by:AriMc
AriMc earned 83 total points
ID: 35101255
0
 
LVL 21

Assisted Solution

by:huslayer
huslayer earned 333 total points
ID: 35101579
I'm not really adding much but I've a screen shot that I would share.
 shrink
0
 
LVL 6

Author Comment

by:anushahanna
ID: 35103054
ok - great. why backup before shrink? does it help the shrink process better?
0
 
LVL 21

Assisted Solution

by:huslayer
huslayer earned 333 total points
ID: 35103148
A full backup doesn't truncate or shrink. Only a transaction log backup will truncate the log and allow shrinkage.

In full and bulk-logged recovery you need log backups to mark log space as reusable. In simple recovery a checkpoint is sufficient (which run automatically)
0
 
LVL 32

Expert Comment

by:ewangoya
ID: 35103254


Full backup will truncate the log, This  marks the virtual logs as inactive that do not hold any part of the logical log.
A shrink operation will then remove the inactive virtual logs
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 21

Assisted Solution

by:huslayer
huslayer earned 333 total points
ID: 35103316
Ewangoya: in respect to you and your Rank  and with no offense at all, we're all here to help and gain more knowledge.

but to what I know. Neither Full or Differential backups truncate the transaction log. During these backups enough of the log is backed up to provide a consistant backup. Transaction Log backups are the only backups that truncate the transaction log of commited transactions.

If you have the database using the Full Recovery model to allow for point in time recovery, you also need to implement transaction log backups between your full and/or differential backups.

http://technet.microsoft.com/en-us/library/ms189085.aspx
0
 
LVL 32

Expert Comment

by:ewangoya
ID: 35103596

My misquote
No offense taken, log is truncated when you backup the transaction log
0
 
LVL 21

Expert Comment

by:huslayer
ID: 35103677

@ewangoya: Cool :)

@anushahanna: if your question has been answered please award 'ewangoya' the points, he actually answered your question first.
0
 
LVL 6

Author Comment

by:anushahanna
ID: 35103780
Shrink->Database affects only the data files, right? not log files?
0
 
LVL 21

Assisted Solution

by:huslayer
huslayer earned 333 total points
ID: 35103876
Yep, when you need to shrink the LOG, you select "files" and then change it to LOG
loggg.jpg
0
 
LVL 6

Author Comment

by:anushahanna
ID: 35143766
thanks a lot for the pictures and explanations.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

743 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

12 Experts available now in Live!

Get 1:1 Help Now