The reason for the failed SQL Server login could be that the default database set for the specific login has been deleted. To fix the failed SQL Server login, the solution is to update the login information to create the default database.
To fix the failed SQL Server login, follow the steps below:
To begin, open the Command Prompt window and enter the following command:
- For SQL 2005:
Use the command below to fix SQL Server login failure:
osql -S SQL01 -d master -U usrlogin -P usrpassword
Execute the following command to adjust the default database for user login: ALTER LOGIN usrlogin WITH DEFAULT_DATABASE=new_default_db
- Explore more: How to Install SQL Server 2019
- For SQL 2000:
Use the command below to fix SQL Server login failure:
Use the command: isql -S SQL01 -d master -U usrlogin -P usrpassword (opens query analyzer, then type the following line) sp_defaultdb 'usrlogin', ' new_default_db'
By executing the commands mentioned by Mytour above to fix SQL Server login failure issues. Additionally, there are some SQL Server login errors related to the SA account that Mytour has mentioned, so you can explore another method to log in to SQL Server. However, it is best, before performing any critical operations, to backup and restore SQL Server to ensure your data and information are always safeguarded, preventing any loss. Best of luck.
