Solved

how to shrink database

Posted on 2013-01-30
2
278 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
[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
2 Comments
 
LVL 40

Accepted Solution

by:
lcohan earned 500 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...
0
 
LVL 24

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.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

688 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