Reset a password for the sa user of a Microsoft SQL Server instance Print

  • reset a password for the 'sa' user, Microsoft SQL Server instance
  • 45

To change a password for the sa user use any of these tools

Using Microsoft SQL Management Studio

  1. Download and install SQL Server Management Studio on your Windows Server.

  2. Once installed, start Microsoft SQL Management Studio. To do this, run the command below in a command prompt:

ssms.exe

 

  • Select Microsoft SQL Server instance for which you want to reset a password from the drop-down list and connect using Windows Authentication.


    Connect_to_Server.PNG

  • In the Object Explorer, expand Security > Logins > right-click on sa to open its Properties.


    SQL_Management_Studio.PNG

  • In the Properties window, set a new password for sa and click OK to apply the changes.


    Login_Properties_-_sa.PNG

Using osql utility in a command prompt

  1. Start a command prompt as an Administrator and list all Microsoft SQL Server instances:

    OSQL -L
    
    Servers:
    WIN-TVSNFL1C14U\MSSQLSERVER2016
    WIN-TVSNFL1C14U\MSSQLSERVER2017

    Note: AS stated by Microsofr here, due to the nature of broadcasting on networks, osql may not receive a timely response from all servers. Therefore, the list of servers returned may vary for each invocation of this option. If the command does not display any server, try to execute it another time.

 

  • In the command below, specify a Microsoft SQL Server instance for which you want to reset a password and replace ***** with your new password. Once done, run the command:

 

osql -S "WIN-TVSNFL1C14U\MSSQLSERVER2017" -E -Q "exec sp_password NULL,'*****','sa'"

    For a remote Microsoft SQL Server instance, use its remote server name or IP address:

osql -S "SERVERNAME or IP ADDRESS\INSTANCE_NAME" -E -Q "exec sp_password NULL,'*****','sa'"

 

If you still unable to reset password and gets this error 'because it does not exist or you do not have permission' refer to this KB


Was this answer helpful?

« Back

<-- removed to be added again -->