Skip to content

Instantly share code, notes, and snippets.

@johnmmoss
Created December 9, 2015 09:38
Show Gist options
  • Save johnmmoss/5916348c7c5b8e4c0c73 to your computer and use it in GitHub Desktop.
Save johnmmoss/5916348c7c5b8e4c0c73 to your computer and use it in GitHub Desktop.
Shrinking a database file
USE AdeventureWorksDb
-- Set the datbase into simple mode which will truncate the log and close any connections
ALTER DATABASE AdeventureWorksDb
SET RECOVERY Simple;
GO
-- Shrink the file
DBCC SHRINKFILE('AdeventureWorksDb_Log')
-- Return reocvery mode back to Full
ALTER DATABASE AdeventureWorksDb
SET RECOVERY Full;
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment