Log in as a different Windows account to SQL Server Management Studio

March 19, 2012

There are times when you’ll need to use Windows authentication to get to SQL Server Management Studio, but the Windows login is not the one you’re currently logged into your computer with.  Perhaps you’re a consultant or IT worker and you have logins in several different domains.  Or if you’re working with an application or enterprise system like SharePoint, you may be using several different service accounts to do the configuration, and one or more of those AD accounts may have SQL permissions that your personal login does not.  It’s crazy to be working “blind,” so you need to get into SQL and see those databases or query them sometimes.

You can try to log into a computer using those accounts, but the quick and easy way is to just use a command line run as that user to open SSMS.  If you use this once, then take the extra ten seconds and make yourself a shortcut, because I guarantee it will come up more than once.  Smile  I have three different shortcuts on my desktop, two for my own account on other domains, and one for the SharePoint install service on my own domain.  Note – the below commands are what I use to get to my own SSMS for SQL Server 2008 R2. Obviously check and adjust to the path of your own SQL installation.

Logging into SQL as an AD account in a different domain:

C:\Windows\System32\runas.exe /netonly /user:[domain name]\[username] "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe"


Logging into SQL as an AD account in your own domain:

C:\Windows\System32\runas.exe /user:[domain name]\[username] "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe"

(So in other words, remove the /netonly if you’re using a Windows account in your own domain).


In either case, you’ll have a cmd.exe window pop up and you’ll be prompted,

Enter the password for [your domain here]\[the username]:

Simply enter the password for the account you’re using and hit Enter.


At that point, if you’ve entered the correct password, SQL Server Management Studio should open.  Select the server you want and be sure to select Windows Authentication.  Now you should be logged into SQL using the AD account that has the SQL permissions you need to do your task.


Kyle from car fleet management March 20, 2012 at 6:02 am

Thanks man this really got me out of a pickle!

Alan from Hip Hop CD Reviews March 24, 2012 at 12:21 pm

This is true as I have had to get to SQL Server Management Studio. I’ll remember to use the command line as that particular user. Thanks a million.

Christie March 24, 2012 at 5:39 pm

@Kyle, @Alan glad it helps!

Database Management April 9, 2012 at 7:43 pm

It helps a lot, because they provide convince as long as you follow the exact procedure.

Glory from Fan-Traffic.com April 18, 2012 at 8:20 pm

It’s awesome designed for me to have a site, which is helpful in favor of my experience. thanks admin

Matt May 9, 2012 at 8:28 am

Thanks! You saved me several MORE hours of pain and agony!

Matt´s last blog post ..When User Profile Synchronization Status Stays Idle

Mark Bennet June 15, 2012 at 5:30 am

Hey this is truly great.I have got a SQL Server Management Studio and I used to find such problems with it. Now I am going to surely follow your blog and try to see if it works or not.

Kurt September 2, 2012 at 3:23 am

Very helpful… I am a database administrator also but thanks that I have quite small users to manage, have this setup on my server will surely help. thanks!

Previous post:

Next post: