Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-03-10
12
Medium Priority
?
289 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:
Ephraim Wangoya earned 336 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 332 total points
ID: 35101255
0
 
LVL 21

Assisted Solution

by:Jason Yousef, MS
Jason Yousef, MS earned 1332 total points
ID: 35101579
I'm not really adding much but I've a screen shot that I would share.
 shrink
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
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:Jason Yousef, MS
Jason Yousef, MS earned 1332 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:Ephraim Wangoya
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
 
LVL 21

Assisted Solution

by:Jason Yousef, MS
Jason Yousef, MS earned 1332 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:Ephraim Wangoya
ID: 35103596

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

Expert Comment

by:Jason Yousef, MS
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:Jason Yousef, MS
Jason Yousef, MS earned 1332 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

885 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