Unlock the SQL Server SA Account

 Applies To 
 Version(s): - Present
 Environment: N/A
 Area: N/A
 Subarea: N/A
 Original Author:Claudio Badalamenti, Bentley Technical Support Group









Warning: Making these changes can cause serious, system-wide problems within your environment. Do not make these changes unless you are confident with these steps and understand the impact to your system and other applications running on it.


System.Data.SqlClient.SqlError: Login failed for user ‘sa’ because the account is currently locked out. The system administrator can unlock it. The error occurs when the SQL Server administrator account is locked. To unlock the SQL Server ‘sa’ account, run the following command:


Enter the existing ‘sa’ password if remembered, otherwise enter a new one.

Option 1 –From MicroSoft SQL Server Management Studio
You will need authority to access the SQL Server directly. Choose Widows Authentication mode and login with an administrator account. Open a new query window, enter the ALTER command and click execute to unlock the ‘sa’ account.

Option 2 –From the command prompt
Using the Windows “Trusted” Connection
SQL Server 2000

OSQL -S SERVER\SQL Instance -E                           
SQL Server 2005\2008

(Using a SQL administrator account)
SQLCMD -S SERVER\SQL Instance -U account name -P Password

Once connected to the SQL Server you will see the 1> prompt. You can type the ALTER DATABASE command and hit Enter. You will see the 2> prompt, type GO and hit Enter to execute the command. Type Exit to log out and close the command prompt.

After unlocking the ‘sa’ account, you will need to open the Bentley SELECTserver Database Setup and enter the new password, if it was changed.