1

I need to test the connectivity of SQL Server with my remote machine,

I have SQL server name not IP address.

How can I check this connectivity. How will I know on which port the communication enabled.

AMIT SHELKE
  • 501
  • 3
  • 12
  • 34
  • Simply try connecting. Knock up a small application that connects to a server using a given connection string. Try it, and see if it works. If you are not using the default port - you can specify this in the connection string; however, without knowing which it is, it's best to ask the server admin or it will be a guessing game (or use a port scanner). – Kami Oct 07 '13 at 09:08
  • inside connection string can I provide the ServerName only, considering I do not have the IP address, Database name, UID and password I am having machine name. – AMIT SHELKE Oct 07 '13 at 09:54
  • 3
    Ask the database admin or the network admin. Depending on how the server or network is setup it may not permit external connections, Making all the suggested answers irrelevant. If the external connections are possible, then you can do something with c#. – Kami Oct 07 '13 at 10:29
  • So you want to find all instances and TCP ports of SQL Server running on a server you only have the DNS name of? – CodeCaster Oct 07 '13 at 11:02
  • @Kami : The condition is like the application server will have access to the SQL Server running on another machine. – AMIT SHELKE Oct 07 '13 at 11:09
  • @AMITSHELKE There is no problem, simply use the DNS name of the other server. Try something like - http://www.developerfusion.com/tools/sql-connection-string/ - which guides you through the process - (Use with care). – Kami Oct 07 '13 at 11:14

3 Answers3

1

You need to try to connect, there is no way find on which port someone is listening without directly asking, hey, is there anyone on this port?

Here is the way to do so from C#:

TcpClient tc = null;
try
{
    tc = new TcpClient("MyAddress", MyPort);
    // port is open
} 
catch(SocketException se) 
{
    // port is not open, or host is not reachable
}
finally
{
   tc.Close();
}
Klark
  • 8,162
  • 3
  • 37
  • 61
0

Well you must know on which port the Sql server services are listening on remote server. Default port is 1433. If you want to test if a port is open on a server or not then you can try Telnet ping.

open command prompt:

C:\> Telnet <YourServername> <portno.>

If it's open then a screen will go empty immediately or return an error.

vendettamit
  • 14,315
  • 2
  • 32
  • 54
0

You need to know the IP address or host name of the server and the TCP port, too. The instance name alone won't help, as they are not advertised on the network. If you have the server's name or IP and the SQL Server instance name, you can simply try to connect using an SqlConnection with an appropriate connection string. If you can connect, everything's fine.

Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139