Preventing accidental schema changes to the master database
June
8th,
2008
If you have ever run some SQL within SQL Server Management Studio only to realise that you’ve run it against the master database by mistake, you’ll know that it can sometimes be hard to undo the damage.
A simple way to stop these accidental changes is to create a database trigger that will prevent any schema changes to the master database:
Any time you attempt to change the master database, SQL Server will fail with an error. If you do want to make a schema change, simply disable the trigger and then re-enable it once the schema change is complete.
(NB. this only works with SQL Server 2005 and above)