Wednesday, March 26, 2008

SQL Server: Restore Your Master

I have been playing around with scripting the drop of all objects within a database and I accidentally ran this today in Master database on my local SQLExpress 2005 instance unintentionally (cough, cough). I have had better days. :-( So I originally thought I was going to have to reinstall SQL Server Express to restore the database, but after a little digging on Google I found this article that shows you can do it with just the following command line:

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Install>sqlcmd -E -S .\SQLEXPRESS -i instmsdb.sql


Whew, that saved me a lot of time. Hopefully, you won't make this same mistake, but if you do, this is a quick way to fix it.

No comments: