dirq.net

Web development tips with a side of sarcasm

How to Run SQL Server Management Studio as a Different Windows User

| 7 Comments

If you’re using Windows Authentication for your SQL Server database you’ll need to run SQL Server Management Studio (SSMS) as that Windows account to test queries.  SSMS normally runs as the user logged in to Windows, but there is a simple way to run it as the database access account.

Just shift-right-click on a shortcut and select “Run as a different user“.  (Windows 7)

Shift-Right-Click a shortcut to run the program as a different Windows User.

Shift-Right-Click a shortcut to run the program as a different Windows User. (Windows 7)

You’ll be presented with a Windows login prompt.  Log in and SSMS will open.  Note that the connection dialog has the new user in the Windows Authentication area

Connect to Server Dialog

Connect to Server Dialog

Note: You’re now running the program as a different user, so it probably won’t have access to the files you normally use.  My fix was to give the account read/write to the folder where I hold my SQL scripts.

This tip will work for other programs too.  Let me know how you used it in the comments below.

Author: Dirk Watkins

Dirk Watkins was born in Door County. He studied computer science and art at Carroll University in Waukesha, Wisconsin. Dirk now works as a web developer in Milwaukee programming mostly in C#, Javascript, T-SQL and the occasional regular expression. For design he likes to utilize as much standard CSS (positioning and styles) as possible. In his spare time Dirk brews beer, plays guitar, reads, listens to NPR, works on his house, and sleeps on quiet beaches.

7 Comments

  1. Well as normal it looks so good on paper but when trying the practical thing there seems to be just one little thing that’s not working. I want to connect to a database that has SQL authentication enabled. My username doesn’t have access so i got a Domain user name and password for connecting to the database. I can’t just type it’s SQL authentication. When i try to open ssms as described above it seems to be working allrtight it’s opening SQL Server management studio. Butt… it’;s just opening with my account :(

  2. Nice trick. But what about if you do not have the password for the login? I want to use SSMS and connect to the subject DB using the dedicated domain id (which only DBA holds the credential), any idea? Thanks.

  3. Very good stuff

  4. @Steve – Good points! Thanks for the tip.

  5. This approach won’t work if the database user is either a different domain or doesn’t have an account on the computer you’re using. In order to get around that you can set up a short-cut with the path “runas /netonly /user:DOMAIN\USER “. This lets you override the domain and also the /netonly flag makes it so that you’re interacting with the local computer as the logged in user and across the network as the network user. This should allow you to avoid having to do anything special for file permissions.

    • Ahh, it ate part of my reply. The command line is:

      runas /netonly /user:DOMAIN\USER “path to Ssms.exe”

      It will pop up a command prompt window to ask you for the password and then launch SSMS.

Leave a Reply