Home > Uncategorized > SQL 2008: Shrink a log file

SQL 2008: Shrink a log file

Update on test database filled up Transaction logs on a SQL Server. They are now big more than 50 GB.

Solution:

(1) Shrink the transaction log

USE TEST

GO

DBCC SHRINKFILE(TEST_LOG1, 1)

BACKUP LOG TEST TO DISK = ‘nul:’ WITH STATS = 10

DBCC SHRINKFILE(TEST_LOG1, 1)

GO

USE TEST

GO

DBCC SHRINKFILE(TEST_LOG2, 1)

BACKUP LOG TEST TO DISK = ‘nul:’ WITH STATS = 10

DBCC SHRINKFILE(TEST_LOG2, 1)

GO

(2) set recovery to simple as it is a test database to avoid this in the future.

ALTER DATABASE TEST SET recovery simple

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: