Change MSSQL2005 Password from Command Prompt
SA is the administrative login for the MSSQL. To Change the MSSQL SA password please use following steps:
Step 1. Go to the command prompt of the server ( Start >> Run >> Cmd ) and type in command
osql –L
This command will list all the MSSQL servers near you.
Step 2. Copy full name of required MSSQL server and type
osql -S copied_servername –E
By this command you’ll connect to MSSQL server using Server administrator account (Windows Authentication).
Step 3. To change sa password you should execute the following query:
1> sp_password NULL,’new_password’,’sa’ 2> go
Here the new_password will be the password which you want to set.
Now try to login to MSSQL using new password.
Another quick way:
OSQL -S MyServer -E -Q "EXEC sp_defaultdb 'sa', 'master'" OSQL -S MyServer -E -Q "EXEC sp_password NULL, 'NewPassword', 'sa'"