Skip to content

Instantly share code, notes, and snippets.

@alexruzenhack
Last active November 27, 2018 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexruzenhack/6904bf88ba63a2c5fa4d5aeba135c56f to your computer and use it in GitHub Desktop.
Save alexruzenhack/6904bf88ba63a2c5fa4d5aeba135c56f to your computer and use it in GitHub Desktop.
💉 Repair #sqlserver database into emergency mode
-- step 01 - Set the database into emergency mode
ALTER DATABASE yourDatabase SET EMERGENCY;
-- step 02 - Emegency mode repair
ALTER DATABASE yourDatabase SET SINGLE_USER
DBCC CHECKDB(yourDatabase, REPAIR_ALLOW_DATA_LOSS);
-- steop 03 - Unlock the database setting it into multiuser again
ALTER DATABASE yourDatabase SET MULTI_USER;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment