SQL Emergency maintenance PowerShell

SQL Emergency maintenance PowerShell

Moving SQL server data files just isn’t something I do very often. And I therefore tent to forget which actions are involved. To solve this, I’ve prepared a Powershell script to automate the steps

SQL Emergency maintenance Script

I do want to address a couple of issues I ran into, instead of just dumping a script; The most important thing to know is that you can’t access the database using SMO when it’s offline. Therefore it’s required to alter the file name before taking the database offline.

In addition, the modification will only alter the system catalog. The new path will be used the next time the database is started.

Post Navigation