how to shrink database

Posted on 2013-01-30
Medium Priority
Last Modified: 2013-02-25
I have 100gb SQL 2005 database FULL RECOVER MODE  and trying to shrink data size by purging some   records.
1. I have to DB live and test. Test database is a copy of live data restored to different file names. however logical name is the same for both.

DBCC SHRINKFILE( Test_log Data, 2)      
log files are getting truncated
delete from my_table
truncate MY TABLE

What is the safe and proper way to shrink DB
Question by:leop1212
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
LVL 40

Accepted Solution

lcohan earned 2000 total points
ID: 38837016
". I have to DB live and test. Test database is a copy of live data restored to different file names. however logical name is the same for both."

Can you connect to that box via SSMS? I suggest use that tool and right click the db you want to shrink, select Tasks - Shink - > Files and go from there...
LVL 25

Expert Comment

by:DBAduck - Ben Miller
ID: 38837914
The easy answer for me about Shrinking a database is DON'T.

When you shrink the database file, everything in it gets very fragmented because of the way it shrinks.  If the database will never grow again to the size you are shrinking it from, then you can shrink it and then rebuild the indexes or reorganize them.

If you are trying to get rid of data in a table, I would use TRUNCATE as it only logs the deallocation of the pages, instead of logging the delete of each row. TRUNCATE is faster.

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

752 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