June 25, 2014

Transaction and Commands for SA Account and Password in SQL Server

SA account is default administrator for SQL Server. No matter Transaction-SQL or Commands, they provide ways to take operations on SA account and its password. And in this passage, we mainly pay attention to how to verify, change, clear SA password with Transaction and commands.

1. Transaction-SQL for SA password

1-1 Verify SA account and its password:
Select * from my usertable where text=’sa’ and password =Password

1-2 Change SA password:
Exec_password ‘old_password’, ‘new_password’, ‘sa’

1-3 Clear SA password:
Exec_password NULL, ‘sa’

This way asks for SQL Server logon, no matter using Windows Authentication mode or SQL Server Authentication mode. But generally, when we remember SA password to login into SQL Server, we would not like to do these. And if you try to access SQL Server with Windows Authentication mode, but failed, turn to this article to find reasons and solutions if necessary:
Why cannot login into SQL Server with Windows Authentication

2. Commands to change/reset SA password:

Osql –E
EXEC sp_password NULL, yourpassword, sa

No comments:

Post a Comment