How to use RunAs command for SSMS if option does not exist

By:   |   Updated: 2012-03-07   |   Comments (17)   |   Related: > SQL Server Management Studio


Problem

As a best practice in the industry, a DBA often has two logins that are used to access SQL Server; one is their normal Windows login and the other is an admin level login account which has sysAdmin rights on the SQL Server boxes. In addition most of the time the SQL Server client tools are only installed on the local desktop and not on the SQL Server Production Box. In order to use the different login to connect to SQL Server using SSMS you need to use the "Run as" feature. What do you do in the case of Windows 7 or Windows Vista where you can't find the Run As Different User option.

Solution

If the Run As different user option is not available while you right click on the SSMS executable or shortcut, you can follow one of the techniques below to use the run as option.

Technique 1 - Run As different User

Step 1: Press and Hold the Shift Key and Right Click on the SSMS executable or shortcut, you should see the Run as different user option in the context menu.

run as different user option

Step 2: Once you click on the Run as different user option the below dialog box will appear. You have to enter the User Name or Domain\User Name and Password to run the application with that user's security context.

run as different user security credentials

Technique 2 - Run As different User using command prompt

Step 1: Go to the command prompt and type runas /? and you should see the Run As help as shown below.

runas command line utility

Step 2: Enter the below command in the command prompt to open SSMS with the different user's security context. It will prompt you for the password; enter the password to run the application.  Here I am entered "aa\jshah" for the domain\user to use.

c:\>runas /user:aa\jshah "C:\Program Files\Microsoft SQL Server\100\Tools\Binn
\VSShell\Common7\IDE\Ssms.exe"

After I run the above comand I am prompted for the password as shown below.

runas command line enter password prompt

Setup a Shorcut to do this

If you are going to use the secondary ID to always to connect to SQL Server, you can create a shortcut to open SSMS with the secondary ID context as shown below. 

Right click on the desktop, go to New and click Shortcut.

creating a shortcut for a runas command

Paste or type the above Run As command into the Target box. Then the next time you open SSMS just use this shortcut to use the Secondary ID.

shorcut properties for runas.exe command
Next Steps
  • If you are not already doing this, you should look into using the two Windows accounts security standards in your organization's database environment
  • Run SSMS on the local machine instead of having to login to the production box
  • Read these other security tips


sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip



About the author
MSSQLTips author Jugal Shah Jugal Shah has 8+ years of extensive SQL Server experience and has worked on SQL Server 2000, 2005, 2008 and 2008 R2.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips


Article Last Updated: 2012-03-07

Comments For This Article




Wednesday, April 17, 2024 - 12:29:58 PM - Tauney Back To Top (92184)
I'm running SSMS 20 on Windows 11 and have to create a shortcut on desktop to see the option to run as different user. Thanks

Wednesday, November 2, 2022 - 11:37:31 AM - Tony Back To Top (90657)
Hi there. This is a great workaround and article. Do you have any means of doing the same for Azure Data Studio on Mac? I tried finding some options but was to no avail.

Tuesday, August 30, 2022 - 10:44:15 AM - Bruce Back To Top (90425)
This process also works with SmartCards as well. If you create a shortcut, Windows will briefly open a command window where it will give you progress updates and allow you to enter your PIN.

Thursday, December 31, 2020 - 9:09:07 AM - Walter Prins Back To Top (87989)
For those running into "Unable to acquire user password", you should try including /netonly, since then it removes the need for a trust relationship between the local and the remote domain. E.g the following should work (from admin prompt):

runas /netonly /user:domain\user "C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\Ssms.exe"

(adjust the path as needed - you can find it with from a command prompt with the dommand "dir C:\ssms.exe /s")

Saturday, September 19, 2020 - 12:09:06 AM - Jugal Back To Top (86504)
did you try running it from command prompt? I am able to run the command for the SSMS 2016 on Windows 10. Could you please confirm the source OS version, SSMS version and do you have admin permission on the client server?

Tuesday, September 15, 2020 - 8:10:19 AM - OndraL Back To Top (86478)
Hi, thanx for this column. but I am facing problem when I run SSMS through RunAs command instead of "Run As Different User" by the same credentials i cant Connect to some of SQL servers (not all). I receive error:

TITLE: Microsoft SQL Server Management Studio
------------------------------

Error connecting to 'work.XXX.xxx,1525'.

------------------------------
ADDITIONAL INFORMATION:

Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. (Microsoft SQL Server, Error: 18456)
------------------------------
BUTTONS:

OK
------------------------------

Is this possible to solve it somehow.
Just for note, when i run SSMS through "Run As Different User" everything works correctly.

Thanx for any spots to this.

Cheers.
Ondrej

Tuesday, August 25, 2020 - 3:02:23 PM - EdneyHolder Back To Top (86359)
This did not work for me. It tries to install a new copy and i get a cannot fine InstallShield2012.msi error.

Tuesday, June 23, 2020 - 12:37:03 AM - Manoj Back To Top (86034)

This worked for me. I had tried many different options but was not able to resolve. Thanks a lot


Monday, February 18, 2019 - 10:47:21 AM - hort Back To Top (79054)

Hello,

It looks interesting but i always have a message : runas error unable to acquire user password

If i put another password, i just have the message thtat password or user is not good.

so do you have an idea of the problem ?

regards


Friday, September 9, 2016 - 4:32:09 PM - JD Back To Top (43291)

 This worked great for me on a SQL 2014 box. Thanks for posting!

 


Friday, March 18, 2016 - 11:38:32 AM - Nadum Charles Back To Top (40992)

 Jugal Shah,

 

Thank you so much for this solution. Ite was spot on.

 

Regards,

 


Wednesday, February 26, 2014 - 8:45:15 AM - Mawande Back To Top (29581)

Best note on this topic. found it very usefull


Wednesday, March 14, 2012 - 5:46:53 AM - kamesh Back To Top (16375)

how to upgrading the sql server 2000 to 2005


Monday, March 12, 2012 - 1:49:43 AM - dips Back To Top (16340)

Nice Post..


Thursday, March 8, 2012 - 10:10:32 AM - Mike Hinds Back To Top (16298)

I've also been required to use a Desktop account (for email, Word, Excel) and an Admin account for anytime I log into a server. I had learned the "{SHIFT} Run As" trick, but my desktop is locked down so hard that it then wants an account that is Admin on the desktop in order to proceed. How could we do both RUN AS (different account) and "Run As Administrator"?


Thursday, March 8, 2012 - 8:36:09 AM - Michael J. Swart Back To Top (16295)

Hi there, Very helpful post. 

Wouldn't it be great if we could connect to a database using different Windows credentials from within SQL Server? I wonder if there's an Microsoft Connect item for that.


Thursday, March 8, 2012 - 7:18:14 AM - Bill Ross Back To Top (16294)

Good, helpful, post. Thanks!















get free sql tips
agree to terms