Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Questions:
To connect to an instance of SQL Server, you need to specify the server in the connection string. However, after the SQL Server installation, you do not know which server name you should input in the connection string is. This article is to let you know how to find the correct server value.
Answer:
To get the server value of a SQL Server instance, the first thing you need to do is to find the instance name.To find the instance name of a SQL Server instance, please follow the steps below:
After you find out the instance name, you can determine whether it is a default instance or named instance. If the instance name is MSSQLSERVER, it is a default instance. Otherwise, it should be a named instance such SQLEXPRESS, SQL2008 and so on. You can install multiple instances on a server but only one default instance.
After you get the instance name and know instance type (default or named instance), you will know the value of server or data source:
For default instance, use <ComputerName> as the server name; and for named instance, use <ComputerName>\<InstanceName> as the server or data source.
Note: If the SQL Server instance is installed on the local server, you can also use localhost, (local), . (dot), 127.0.0.1 (the IP address of localhost), and local IP address and <ComputerName>. If the SQL Server instance is installed on the different trusted domain, you may need to use full computer name such as ComputerName.domain.corp.company.com instead of <ComputerName>. If the SQL Server installed is public network environment, you may need to use IP address instead of <ComputerName>. If you just know the IP address/computer name and the TCP port for a SQL Server named instance, you can use "tcp:<server ip address/computer name>,<TCP port>" as the value of server or data source.
Once we get the server value, we can make connections to the SQL Server instance with the correct connection string as follows:
Server=WinSrv1\SQL2008;Database=myDataBase;UID=myUsername;PWD=myPassword;
orData Source=WinSrv1\SQL2008;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
References
Using Named Instances
https://msdn.microsoft.com/en-us/library/ms165614(SQL.90).aspx;
Localhost
https://en.wikipedia.org/wiki/Localhost.
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in