FIX: Cannot Execute SELECT COUNT(*) Against DB2 on Mainframe Using Four-Part Name

Article translations Article translations
Article ID: 296685 - View products that this article applies to.
This article was previously published under Q296685
BUG #: 352492 (SHILOH_BUGS)
Expand all | Collapse all

On This Page

SYMPTOMS

When you execute a SELECT COUNT(*) statement to retrieve the count of all records in a table against a linked DB2 server on a mainframe that is using it's four-part name, the following error message occurs:
Server: Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing a query for execution against OLE DB provider 'DB2OLEDB'.
[OLE/DB provider returned message: A SQL error has occurred. Please consult the documentation for your specific DB2 version for a description of the associated Native Error and SQL State. SQLSTATE: 42601, SQLCODE: -104]

CAUSE

SQL Server parses a SELECT COUNT(*) statement as SELECT COUNT((0)) for all providers. This can be observed by creating a DB2 internal trace in the Trace utility that is provided with Microsoft SNA Server 4.0 and Host Integration Server 2000.

The OS/390 version of DB2 server that runs on a mainframe cannot work with the format of SELECT COUNT((0)) and causes the error message to occur.

RESOLUTION

To resolve this problem, obtain the latest service pack for SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack

STATUS

Microsoft has confirmed that this is a problem in SQL Server 2000. This problem was first corrected in SQL Server 2000 Service Pack 1.

MORE INFORMATION

SQL Server allows you to create linked servers to access distributed, heterogeneous OLE DB data sources. After a linked server is successfully created, you can execute distributed queries against the linked server by using the following methods:
  1. Four-part name in the form of:

    LinkedServerName.Database/Catalog.Owner/Schema.Object
  2. OPENQUERY
  3. OPENROWSET
  4. OPENDATASOURCE
For more information about these methods, refer to the "Accessing External Data" topic in SQL Server Books Online.

Steps to Reproduce Behavior

Execute a SELECT statement in the following form after you successfully create a linked server to the DB2 server on a mainframe:
SELECT COUNT(*) FROM LinkedDB2ServerName.Catalog.Schema.Table
				
For more information about creating a linked server to the DB2 server, refer to the "sp_addlinkedserver" topic in SQL Server Books Online.

Properties

Article ID: 296685 - Last Review: February 22, 2007 - Revision: 4.3
APPLIES TO
  • Microsoft Host Integration Server 2000 Standard Edition
  • Microsoft SQL Server 2000 Standard Edition
Keywords: 
kbbug kbfix kbsqlserv2000sp1fix KB296685

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com