Wednesday, November 17, 2010

Shrink Logfile in SQL 2008

I know that there's a great deal of debate on whether Shrinking a database and it's log is healthy. However, there will always be a situation that shrinking the log file is the only option you have. Here's the code that will shrink the database log in SQL 2008
declare @LogFileLogicalName sysname
select @LogFileLogicalName=Name from sys.database_files where Type=1

select @LogFileLogicalName

DBCC Shrinkfile(@LogFileLogicalName,100)


~~ CK

No comments:

Post a Comment