recover SA password mssql 2008

i recently forgot my sa user’s password and i had to create a new db on my sql server .. bummer!
so, i looked in many blogs and stackoverflow answers and couldn’t find a quick way to do it.

i had admin access to the server, no sql management studio installed on it so i had to use command line..
i could install ‘management studio’ and login with my windows account but i choose an easier solution:

go to command prompt by typing Start – Run – cmd

at the command window (without needing to change directories or anything) type (enter for each line)

OSQL -S instancename -E (where instancename could be something like : localhost\sql or localhost\sqlexpress or localhost\sqlexpress,1433)
1> EXEC sp_password NULL, ‘yourpassword’, ‘sa’
2> GO

you can use this method to replace the password of any user not only SA and it should work on other versions of mssql.

enjoy :)

Posted in General

Leave a Comment