Solved

how to shrink database

Posted on 2013-01-30
2
262 Views
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.

BACKUP LOG TEST WITH TRUNCATE_ONLY
DBCC SHRINKFILE( Test_log Data, 2)      
log files are getting truncated
when I do QUERY ON MY TEST DB
delete from my_table
truncate MY TABLE
DBCC SHRINKFILE(LIVE_DATA, 3)

What is the safe and proper way to shrink DB
0
Comment
Question by:leop1212
2 Comments
 
LVL 39

Accepted Solution

by:
lcohan earned 500 total points
Comment Utility
". 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...
0
 
LVL 24

Expert Comment

by:DBAduck - Ben Miller
Comment Utility
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.
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

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 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

9 Experts available now in Live!

Get 1:1 Help Now