Sean Lange (9/6/2013)
Michael Valentine Jones (9/6/2013)
It might be more valuable if you explained the implications of changing the default database, and especially the disadvantages of having a default database that is not master for an admin login.Other wise, the article could be one line:
exec sp_defaultdb N'MyDomain\MyLogin', N'MyDatabase'
Thanks for validating that this really does deserve an article. That proc is deprecated in favor of ALTER LOGIN. 😀
You could just change the article to:
-- Works with any version
exec sp_defaultdb N'MyDomain\MyLogin', N'MyDatabase'
-- Works with SQL 2005 and later
ALTER LOGIN [MyDomain\MyLogin] with DEFAULT_DATABASE = [MyDatabase] ;