Microsoft SQL Server – How to verify connection information using SQLCMD

quesstion: How to Verify Connection Information to Microsoft SQL Server using SQLCMD?

When you are trying to connect a MS SQL server, if the incorrect information is specified, the following error can occur during database creation or migration:

Database Server Error: Named Pipes Provider: Could not open a connection to SQL Server [1231].

A simple way to verify the connection information is to use it to connect to SQLCMD, which is automatically installed with Microsoft SQL Server. To connect to SQLCMD, you’ll need to know the following information:

  • server name or IP address
  • database instance name (if you are using a default instance, this piece of information is not necessary)
  • system admin (sa) password

To test the connection information:

1. Open a Command Prompt window on a server where Microsoft SQL Server is installed.

2. Run the following command:

sqlcmd [server name or IP address]\[named instance] -U sa -P [sa password]

For example:

sqlcmd sqlserver01\labdb -U sa -P password

3. The connection is successful when the command is followed by the one (1>) prompt:

C:\>sqlcmd sqlserver01\labdb -U sa -P password
1>
Related Post