Article ID: 280102
Article Last Modified on 3/16/2004
APPLIES TO
- Microsoft SQL Server 2000 Standard Edition
- Microsoft SQL Server 7.0 Standard Edition
This article was previously published under Q280102
IN THIS TASK
- SUMMARY
- Set up a linked server to a Sybase database server
- Troubleshoot problems that may occur
- REFERENCES
SUMMARY
This step-by-step article describes how to set up a linked server to a Sybase database server on a computer that is running Microsoft SQL Server. Additionally, this article contains basic troubleshooting steps for problems that may occur when you set up a linked server to a Sybase database server.
back to the top
Set up a linked server to a Sybase database server
To set up a linked server to a Sybase database server, follow these steps:
- Log on to the computer that is running SQL Server.
- Install the Sybase client software on the computer.
- To connect to the Sybase database server, install the appropriate driver on the computer. You can use the Microsoft OLE DB Provider for ODBC to connect to the Sybase database server.
Note You can also use a third-party driver or provider to connect to the Sybase database server. If you use a third-party driver or provider, you must contact the third-party vendor for any problems that occur with the driver or with the provider. - After you install the Sybase client software, restart the computer.
- Make sure that you can successfully connect to the Sybase database server by using the Sybase client software that you installed in step 2.
Start SQL Query Analyzer, and then run the following Transact-SQL statement to set up a linked server to a Sybase database server.
Note This script uses the Microsoft OLE DB Provider for ODBC to connect to the ODBC driver for Sybase. ReplaceSybase Linked Server Name
,Sybase System DSN
,User Name
, andStrong Password
with the appropriate linked server name, System DSN, user name, and password.-- Adding linked server: exec sp_addlinkedserver @server = 'Sybase Linked Server Name' , @srvproduct = 'Sybase', @provider = 'MSDASQL', @datasrc = 'Sybase System DSN' -- Adding linked server login: sp_addlinkedsrvlogin @useself='false ', @rmtsrvname = 'Sybase Linked Server Name', @rmtuser = 'User Name', @rmtpassword = 'Strong Password'
To make sure that the linked server is set up correctly, run the following Transact-SQL statement:
EXEC sp_linkedservers
The name of the linked server that is connected to the Sybase database server may be listed in the output.
Troubleshoot problems that may occur
If a problem occurs when you set up a linked server to a Sybase database server, follow these steps to troubleshoot the problem:
- Make sure that the Sybase client software is correctly installed on the computer that is running SQL Server.
- Make sure that the following paths are included in the PATH environment variable on the computer:
Sybase_Home_Path
\binSybase_Home_Path
\dllSybase_Home_Path
\asep
- Verify the network connectivity between the client computer and the server computer. To do so, follow these steps:
- On the computer that is running SQL Server, type the following command at a command prompt, and then press ENTER:
pingSybaseServerName
- On the Sybase database server, type the following command at a command prompt, and then press ENTER:
pingSQLServerName
If you cannot ping the server by using the server name but you can connect to the servers by using the IP address, contact your network administrator to resolve the problem. - Check to see if you can connect to the Sybase database server by using the Sybase client software that you installed on the computer that is running SQL Server.
- If a distributed transaction is configured, make sure that the Microsoft Distributed Transaction Coordinator (MS DTC) service is running.
- Use the sp_addlinkedsrvlogin system stored procedure to map to the correct authentication information about the Sybase database server, and then connect to the Sybase database server.
- Use the client tools to configure and to test the connection to the Sybase database server.
- On the computer that is running SQL Server, type the following command at a command prompt, and then press ENTER:
- Make sure that the ODBC DSN-related configurations are correct. To do so, follow these steps:
- Use the ODBC Test tool or similar software to test the DSN configuration.
- Create a new DSN for the Sybase database server, and then test the connectivity to the Sybase database server by using the new DSN.
If the issue with DSN is not resolved, add the linked server to the Sybase database server with a provider string by using a SQL script that is similar to the following:
EXEC sp_addlinkedserver @server = 'Sybase Linked Server Name', @srvproduct='Sybase' @provider = 'MSDASQL' , @provstr = 'DRIVER={<Driver Name};SRVR=Sybase Server Name;UID=User Name;PWD=Strong Password'
- Verify the Microsoft Data Access Components (MDAC) installation and the Sybase ODBC driver installation. To do so, follow these steps:
- Install the latest version of MDAC. For more information about the latest version of MDAC, visit the following Microsoft Web site:
- Make sure that the following registry entry for the ODBC System DSN contains the correct value for the driver path:
HKEY_LOCAL_MACHINE\Microsoft\Software\ODBC\odbc.ini\<ODBC System DSN>\Driver
By default, the value of the registry entry is C:\WINNT\system32\Sysybnt.dll.
- Use SQL Query Analyzer to run Transact-SQL statements on the linked server to identify any errors that may occur when you connect to the linked server. To do so, follow these steps:
Run the following Transact-SQL statement to make sure that the tables in the Sybase database can be viewed:
exec sp_tables_ex 'SybaseLinkedServerName'
Run the following Transact-SQL statements to query the Sybase database server by using the four-part name syntax and the OPENQUERY Transact-SQL statement:
Statement 1
DBCC TRACEON(3604, 7300) go SELECT * FROM SybaseLinkedServerName.DatabaseName.Owner.TableName go
Statement 2
DBCC TRACEON(3604, 7300) go SELECT * FROM OPENQUERY(SybaseLinkedServerName, "Select * from DatabaseName.Owner.TableName") go
Note If you run the DBCC TRACEON (3604, 7300) statement, and then you run the Transact-SQL statement, you may see additional information in the error message. The information that you see depends on the provider that you use.
Troubleshoot common problems
If you use SQL Query Analyzer to query data from the linked server that is connected to the Sybase database server, you may experience problems. The following list includes some of the possible problems and the methods that you can use to troubleshoot each problem:
Problem 1
You receive the following error message:
Check to see if the System DSN that was used to create the linked server is correct. If you used a provider string to configure the linked server, you must make sure that the driver name in the provider string is correct.
Problem 2
You receive the following error message:
Check to see if the server name that was used to configure or to create the linked server is correct. If you used a provider string to configure the linked server, make sure that the server name in the provider string is correct.
Problem 3
You receive the following error message:
Check to see if the user name and the password that were used to configure or to create the linked server are correct. If you used a provider string to configure the linked server, make sure that the user name and password in the provider string are correct.
Problem 4
You receive the following error message:
If you use a four-part name syntax to query the data from the linked server database, you may receive this error message. To work around this problem, you can use the OPENQUERY syntax to query the data from the linked server database. You can turn on trace flag 7300 to receive more detailed information about this error message. To turn on trace flag 7300, run the following Transact-SQL statement:
DBCC TRACEON(7300)
Problem 5
You receive the following error message:
You may receive this error message when you install the ODBC driver for Sybase. You may be able to resolve this problem by installing the latest version of MDAC.
Problem 6
If you try to run the remote stored procedures on the linked Sybase database server, the linked server may stop responding. This problem occurs because SQL Server does not support running remote stored procedures on database servers other than the instance of SQL Server.
back to the top
REFERENCES
For more information about linked servers in SQL Server, visit the following Microsoft Web site:
For more information about optimizing distributed queries, visit the following Microsoft Web site:
For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
137637 INF: ODBC connections to Sybase SQL Servers
239883 FIX: SYBASE CT-Library clients cannot connect to Microsoft SQL Server 7.0
314530 PRB: Error message 7399: "Timeout expired" occurs with linked server query
255097 BUG: Error 7356 from a distributed query
The third-party products that this article discusses are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.
back to the top
Additional query words: Sybase linked server distributed query
Keywords: kberrmsg kbhowtomaster kbtshoot kbregistry kb3rdparty kbsybase kbclientserver KB280102