Rename the SA Account in SQL Server (T-SQL Example)

A common security precaution you should consider when administering SQL Server is to rename the sa login.

In addition to renaming this account, you should also disable it altogether and then create other admin accounts to be used instead of sa.

The sa account is widely known as “THE” admin account and therefore it’s a perfect target for hackers. Disabling this login prevents hackers from being able to use it to hack your system, and renaming the account can provide an extra layer of protection.

To rename the sa account, simply use the ALTER LOGIN statement.

Example of Renaming the Account

Here’s an example of renaming the sa account using T-SQL.

USE Master;
ALTER LOGIN [sa] WITH NAME = [Homer]

This example renames the sa login account to Homer.

As mentioned, it’s good practice to disable the sa account altogether. And while you’re at it, why not change its password. It’s only one line of code, and it’s one more extra precaution towards securing your environment.