I have to connect remotely to MSSQL database from my local machine, using remote server windows Authentication.
-
Are you on the same network and windows domain? – Sir Swears-a-lot Mar 09 '17 at 08:24
-
What software are you trying to connect to SQL with? – Sir Swears-a-lot Mar 09 '17 at 08:41
-
Has someone created a login for you on the server? Whoever did that should be able to provide you with the details. – Sir Swears-a-lot Mar 09 '17 at 08:42
-
I am in same network but need to log in with different domain credentials to connect SQL server. – Poonam Rupanavar Mar 09 '17 at 09:38
-
we don't want to use any software such as SSMS, we are aware about the SSMS approach. we are interested to do it using cmd or powershell commands. – Poonam Rupanavar Mar 09 '17 at 09:41
-
yes we have the access to the server and database also. – Poonam Rupanavar Mar 09 '17 at 09:41
-
Please edit your question to specify that you need to use different credentials. – Sir Swears-a-lot Mar 09 '17 at 18:04
2 Answers
Assuming you are in a different domain, you can launch SSMS using the remote Windows commercials. Open a command prompt in the folder where ssms.exe lives, and run:
runas /netonly /user:remotedomain\remoteuser ssms.exe
You will be prompted for your password. SSMS will be using remote Windows credentials even though several UI elements will look like you're using the local ones.
This technique should work for launching other executables, like sqlcmd or powershell, but I haven't tested those. I know it works for SentryOne and Plan Explorer.
You can also use Credential Manager, which I wrote about (in addition to more details about runas) here:
- 180,303
- 28
- 400
- 614
-
@Anton I wonder if you could try something like this - use powershell to call powershell. – Aaron Bertrand Mar 09 '17 at 12:58
-
I can confirm that the /netonly trick works for PowerGUI and PowerShell, but I only used it through the SMO objects. – Jonathan Fite Mar 09 '17 at 13:14
-
1Correction:
runas /netonly /user:remotedomain\remoteuser powershell.exeworked. – Anton Krouglov Mar 09 '17 at 16:18
There are few different methods.
Assuming: you are logged into windows, on the same network, and the same domain:
You can connect using the server name or you can use the ip address of the server.
From sql server management studio: click connect > data engine. Enter the server name or ipaddress. Make sure windows authentication is selected and click login.
Provided that you have been granted login privileges on the sql server it should allow you to connect.
This microsoft guide has instructions including screen shots
There are some variations on the theme above such as if the data is a named instance rather than using the default name. But generally if you have been setup to use windows authentication you just need to know the server.
If you are using other products and connecting via ODBC you may need to configure a connection first.
- 3,233
- 2
- 28
- 48