How to Open SSMS as a Different Domain User

If you’re connecting to SQL Server within a corporate environment, you might need to connect to SQL Server using a different Domain User account. This can be done by opening SQL Server Management Studio (SSMS) as a another user, which I’ll demo in this post.

Connecting to SQL Server with a a different Domain User is needed if your currently logged in user is not on the same Active Directory (AD) Domain as the SQL Server you want to connect to.

Topics Covered:
1. How to Open SSMS as Different User
2. Create PowerShell Script to Open SSMS as Another User

1. How to Open SSMS as Different User

This part shows you how to connect to SQL Server with a user that is not your currently logged in Domain User, using SQL Server Management Studio (SSMS).

Open SSMS as Different User:
Locate the SSMS shortcut in the Start Menu or Taskbar.
While holding the Shift Key, right-click the SSMS shortcut, and select Run as a different user.

Open SSMS as Different Domain User

Enter your Domain Credentials as prompted.
For AD Domain User accounts you should be including the Domain prefix as shown below (pwlab\).

SSMS auth as different user

Even though the connect to server window will still show your currently logged in Domain, SSMS will connect using the login details provied.

SSMS Connect as Different User Ignore Domain

2. Create PowerShell Script to Open SSMS as Another User

Now that we know how to connect to SQL Server using a different Domain User account, we’ll now look at doing this using a PowerShell Script. This is useful if you need to do this often – creating this script and saving as a shortcut will save you from some of the steps above in this post.

We can open SSMS as different user by running the command below in a PowerShell Terminal:

# Open SSMS as another user
# amend domain\username before running
C:\Windows\System32\runas.exe /user:domain\username /netonly "C:\Program Files (x86)\Microsoft SQL Server Management Studio 19\Common7\IDE\Ssms.exe"
Run SSMS as Different User via Command Line

You can save this command by simply opening a new Notepad, copy/paste the command and save to your desktop as a .ps1 file. When you run the file you’ll be prompted to enter the password for the Domain User defined within the PowerShell script.

Note: The path used to call SQL Management Studio in this script is tailored to SSMS version 19. You should amend the path to reflect your current version.

Hope this guide was a useful one for you! Feel free to add a comment if there’s room for improvement here.



Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts
Categories
Tags

Always On Availability Groups (AAG) (4) AWS (4) AWS Redshift (6) Database Admin (72) Database Backups & Recovery (14) Database Mirroring (2) Error Messages (5) Failover Cluster Instances (FCI) (1) Git Commands (6) Importing & Exporting Data (2) Linked Servers (3) Linux Administration (2) Logging & Monitoring (1) Microsoft Patching (2) MySQL (4) Postgres (6) PowerShell Scripts (2) SQL Certificates & Encryption (3) SQL Server Agent (5) SQL Server CDC (2) SQL Server Data Types (2) SQL Server Management Studio (SSMS) (17) SQL Server Networking (3) SQL Server on Linux (1) SQL Server Patching (2) SQL Server Performance Tuning (6) SQL Server Processes (SPIDs) (7) SQL Server Replication (2) SQL Server Scripts (13) SQL Server Security (4) SQL Server Storage (10) Windows Admin (20) Windows Authentication (2) Windows Automation (1) Windows Events (2) Windows Firewall (4) Windows Subsystem for Linux (WSL) (18)