To change a password for the sa user use any of these tools
- Microsoft SQL Management Studio
- osql utility in a command prompt
Using Microsoft SQL Management Studio
-
Download and install SQL Server Management Studio on your Windows Server.
-
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.
-
In the Object Explorer, expand Security > Logins > right-click on sa to open its Properties.
-
In the Properties window, set a new password for sa and click OK to apply the changes.
Using osql utility in a command prompt
-
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