Protect the master database part 2
I got lots of good feedback from the last post. As I mentioned, I really think the upcoming DDL_ALL will make it almost trival code. Also, just a note: I went for CHARINDEX rather than an XML query for performance and simplicity.
What I've also suggested to the dev team (via Dave Lean) is that we really should have a server option (in the advanced options list) that simply prevents these errors in the first place. I'd suggest that 99.9% of DDL mods in master are in error and SQL Server should provide support to avoid these.
Setting admin user default databases to tempdb is another option but I think it has the potential to break other things.