Export (0) Print
Expand All

Connecting to Multiple Instances of SQL Server

SQL Server 2000

  New Information - SQL Server 2000 SP3.

Multiple instances of Microsoft® SQL Server™ 2000 can be run on one computer. The computer can support a default instance of SQL Server and additional named instances of SQL Server. An application connects to the default instance of SQL Server by specifying the name of the computer. To connect to a named instance, the application specifies both the computer name and the instance name using this format: '<computername>\<instancename>'

Examples
A. Using ADO and SQLOLEDB to connect to a default instance of SQL Server

The following Microsoft Visual Basic® code fragment shows use ADO and SQLOLEDB to connect to a default instance of SQL Server.

'Initialize variables.
Dim cn As New ADODB.Connection
Dim provStr As String
'Specify the OLE DB provider.
cn.Provider = "sqloledb"
'Specify a connection string for the default instance
'of SQL Server.
ProvStr = "Server=NorthRegion;Database=northwind;Trusted_Connection=yes;"
cn.Open ProvStr
B. Using ADO and SQLOLEDB to connect to a named instance of SQL Server

The following Visual Basic code fragment shows how to use ADO and SQLOLEDB to connect to a named instance of SQL Server 2000.

Note  To connect to an instance of SQL Server, you must have the latest version of Microsoft Data Access Components (MDAC) installed on both computers. The latest version of MDAC is installed automatically with SQL Server 2000; however, if you are using SQL Server 7.0, 6.5, or 6.0, you need to install the latest version of MDAC.

'Initialize variables.
Dim cn As New ADODB.Connection
Dim provStr As String
'Specify the OLE DB provider.
cn.Provider = "sqloledb"
'Specify a connection string for an additional instance
'of SQL Server.
ProvStr = "Server=NorthRegion\Inst02;Database=northwind;Trusted_Connection=yes;"
cn.Open ProvStr

Note  To connect to a named instance using JScript, use this format: '<computername>\\<instancename>'

Show:
© 2015 Microsoft