I'm trying to log in to a SQL Server 2005 Express instance using the following command:
osql -S .\INSTANCE -U sa -P password
I get the error: Login failed for user 'sa'.
I can connect just fine using the -E switch. I must add that it's been working for months. I think someone changed something but I cannot figure out what is it.
This is what I tried:
-
Login using Windows authentication and changing the sa password:
sp_password NULL, newpassword, 'sa'
-
Enabling 'sa' login:
ALTER LOGIN sa ENABLE ;
GO
ALTER LOGIN sa WITH PASSWORD = 'newpassword' ;
GO -
Checked the Windows Registry to ensure that mixed authentication is enabled. The value was correct: LoginMode=2
What else should I check? Thanks in advance.
ADDITIONAL INFO:
This is a Windows 2003 Server. They have some password policies enabled, I remember that I needed to change the default 'sa' password my application uses when it installs SQL Server to another one more complex.
I'm connecting using VNC, so I can't really use SSMS
My application can connect using another SQL Server login, but no 'sa'
Finally, if we don't find a solution I will remove this instance and install it again, but I'd really like to find out what's the problem. Just in case it happens again and just for plain curiosity.
Best Answer
Like @SpaceManSpiff said, don't forget to check if Mixed mode is enabled. Someone changed that setting for me and I had the same problem. Here is how to solve it:
Source: http://forums.eukhost.com/f15/login-failed-user-sa-microsoft-sql-server-error-18456-a-12544/