This is an awesome trick I learned from Greg Howe, (all credit to him). While having to connect to another network and have the need to run queries on a db on that network, I usually had to remote in to that machine and run the queries. Well that is no longer the case. Create a batch file called “Launch SSMS.bat” and another one call “Launch Profiler.bat”. Inside those paste the following:
C:\Windows\System32\runas.exe /netonly /user:[domain]\[username] “C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe”
C:\Windows\System32\runas.exe /netonly /user:[domain]\[username] “C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\Profiler.exe”
Now when I am connected to the client’s domain and double click the “Launch SSMS.bat” file I get the following:
I enter my password and it launches SSMS:
Enter your servername in and don’t worry that your user name shows your currently logged in username, it will run SSMS as the credentials in the batch file. Hit connect and then voila, you can now run your queries locally.