How-To

How to Change the SQL sa Password from a Command Prompt

Aseem Kishore
1 min read

The Back Room Tech is reader-supported. We may earn a commission when you buy through links on our site. Learn more.

To change the SQL sa password from a command prompt:

Start a command prompt by typing Start – Run – cmd

Enter the following commands, pressing Enter after each line

OSQL -S yourservername -E
     1> EXEC sp_password NULL, 'yourpassword', 'sa'
     2> GO

Where yourservername is the name of your server and yourpassword is the new sa account password.  Type exit twice to return to the server desktop.

This works in SQL 2005, I don’t have access to other versions so I can’t say if it will or won’t work other versions of SQL.