Geeks With Blogs
Nagendra Prasad

In most of the DBs in the server will have more space, when the backup is used to store it in the development environment or testing environment, it might not have much data, but it will occupy more space physically.

To reduce the database size, then there is a way to reduce it. Shrink the Transactional Log. There are two ways of shrinking the Transaction Log. One is through Front-End and another is manual script.

Front-End:

Databases -> DbName. Right click on the DbName, then go to Tasks->Shrink->Files.
Here both the Data and Log files can be shrinked. you can see the amount of unused space in this window.

Script: 

-- Shrink the Transaction Log
USE DatabaseName
GO
DBCC SHRINKFILE(<TransactionLogName>, 1)
BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY
DBCC SHRINKFILE(<TransactionLogName>, 1)
GO

If you have any problems/confusions with the TransactionLogName, it will be stored in the table and it can be retrieved using:

select * from sys.database_files

I came across this issue, I had the database backup of 3GB .bak file. Once it is restored in the development environment, it occupies 80GB of space in which Transactional Log is nearly 70GB. I resolved it by doing the above.

I just want to share this, so that anyone else facing the same problem may get benefit out of this.

 

Posted on Friday, August 21, 2009 1:21 PM | Back to top


Comments on this post: Reduce size/Shrink Transaction Log of the DB - SQL Server

# re: Reduce size/Shrink Transaction Log of the DB - SQL Server
Requesting Gravatar...
Good tips top Purging large DB quickly.

Venkat
Left by Venkat on Sep 13, 2009 11:34 PM

# re: Reduce size/Shrink Transaction Log of the DB - SQL Server
Requesting Gravatar...
Very professional, but if there is a software, can easily do these things.
Left by Black Office Desks on Dec 03, 2010 8:43 PM

Your comment:
 (will show your gravatar)


Copyright © nagendraprasad | Powered by: GeeksWithBlogs.net