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)

Shrinking all log files (or data files) on SQL Server 2005

By stalley-gordon,

This can be run as a job or manually. There are no parameters so it will do ALL log files that it finds; excluding system files.

If you want to shrink all database files including data files (and indexes) then find these lines of code:

SELECT @exec_stmt = 'INSERT INTO #logfiles
SELECT ''' + @DBName + ''' , name FROM ' + quotename(@DBName, N'[') + N'.dbo.sysfiles
WHERE groupid = 0'

and replace it with this code:

SELECT @exec_stmt = 'INSERT INTO #logfiles
SELECT ''' + @DBName + ''' , name FROM ' + quotename(@DBName, N'[') +N'.dbo.sysfiles'

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

query(dbname,size,recoverymodel)

query(dbname,size,recoverymodel)

FORUM

query(dbname,size,recoverymodel)

query(dbname,size,recoverymodel)

FORUM

Cursor - passing @dbname to INSERT STATEMENT

Concatentaion of @dbname from cursor + table name to use in FROM clause

FORUM

Alter Database DBNAME Set Recovery Full. Gives error.

Alter Database DBNAME Set Recovery Full. Gives error.

FORUM

query to get dbname,totalsize,reservedsize of all databases in sql 2000

query to get dbname,totalsize,reservedsize of all databases in sql 2000

Tags
dbcc    
log file    
shrink    
shrink database    
sql server 2005    
 
Contribute