Launch Sql Configuration Manager under Configuration Tools folder.
Look for your SQL Server instance (the default is MSSQLSERVER) and stop the service. You can click the stop button while having the SQL Server (MSSQLSERVER) row highlighted or you can right-click on it and select Stop.
Launch the Command Prompt.
Next, we want to run the SQL Server in a single-user mode by adding “/m” parameter with the client application name:
net start MSSQLSERVER /m"SQLCMD"
Then we need to connect to the database on the machine using a trusted connection:
sqlcmd -E -S localhost
After starting the sqlcmd, type the following SQL statement after the prompt
CREATE LOGIN tempUser WITH PASSWORD = ‘newpassword’
ALTER SERVER ROLE sysadmin ADD MEMBER tempUser
For SQL Server 2012 or newer, use ALTER SERVER ROLE should be used instead of sp_addsrvrolemember as this system stored procedure will be removed in a future version of Microsoft SQL Server.
You can type “exit” to quit SQLCMD.
Restart the Sql Server service to get out of the single-user mode:
net stop MSSQLSERVER followed by
net start MSSQLSERVER
Launch SQL Server Management Studio and connect to the local database using the new login you just created.
Expand on Security, then expand on Logins.
Right-click on user sa and select Properties. Enter the new password and click OK. And you’re done.
Now you can login to the database using the sa login and the new password you set. For security purpose, make sure you delete the tempUser afterwards.