Troubleshooting SQL errors

Some of the errors I've come accross and how to resolve them:

Cannot open user default database. Login Failed

This occurs when you have deleted the database that your login uses as the default database.
If you still have your connection open to the database engine then run the following sql command:

alter login [petelaptop\pete] with default_database = master

if you have lost your connection you have to connect as follow using the command prompt:

sqlcmd -d master -U <<your username here>>
-P <<your password here>>

(this will connect using the master database rather than the default which is now deleted.)


What's your thoughts on this?


Protected by WP Anti Spam