Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Shrink DB and Log

By Jack Blade,

Scroll down to the line where it mentions;

--This is the name of the database for which the log will be shrunk.
USE [databasename] put the logical name of the database to replace the database name

Also where it mentions;

--Use sp_helpfile to identify the logical file name that you want to shrink.
SET @LogicalFileName = 'database_Log';

Do the same here replace the database_log for the database log name.

Run the script, if it doesn't run then it's down to the logical name of the database that isn't right.

This has been tested on SQL 2000, 7 and 2005 databases very successfully. 40 GB went down to under 1 GB, 176GB went down to 105MB

Make sure that you understand the implications of this script on the backup and recovery of your database(s): Managing Transaction Logs.

Total article views: 13760 | Views in the last 30 days: 3
Related Articles

Changing SQL Server Database Logical Names

SQL Server Databases are made up of physical and logical names. This article goes over the logical n...


Change file logical name for mirror database

Today I encountered a interesting issue when rename logical name for mirror database. We have a d...


Multiple Database or 1 DB with logical broken up by Filegroups?

Correction to title. Should have read Multiple Databases or 1 Database Logically broken up by fileg...


Need a tool to represent my Logical and physical database model

Need a tool to represent my Logical and physical database model


Where Logic Lives

We recently published an article about logic in the database about how you might structure the TSQL ...


Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones