Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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: 13775 | Views in the last 30 days: 0
 
Related Articles
ARTICLE

Changing SQL Server Database Logical Names

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

BLOG

Change file logical name for mirror database

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

FORUM

Logical Reads

Logical Reads

FORUM

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

FORUM

Need a tool to represent my Logical and physical database model

Need a tool to represent my Logical and physical database model

Tags
shrinkfile    
 
Contribute