Microsoft KB Archive/171178

= ACC97: Wrong Sort Order in Large, Linked SQL Server Tables =

Article ID: 171178

Article Last Modified on 1/20/2007

-

APPLIES TO


 * Microsoft Access 97 Standard Edition
 * Microsoft SQL Server 6.0 Standard Edition
 * Microsoft SQL Server 6.5 Standard Edition

-



This article was previously published under Q171178



Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
Records from a linked SQL Server table are sorted incorrectly in Microsoft Access datasheets and forms if the following conditions are true:


 * A Microsoft Access user opens a long-running query or a form based on a long-running query.
 * The query returns records ordered by one or more columns.
 * The Microsoft Access user and/or other users delete records to which the query conditions apply.
 * The records are deleted before the keyset of the query is completely built (the total number of records in the keyset is not yet displayed at the bottom of the query window).



CAUSE
This behavior is caused by a timing issue between SQL Server and Microsoft Access.



RESOLUTION
Although some of the records will appear out of sort order in the keyset, they are sorted correctly on the server.



MORE INFORMATION
The following procedure requires that you to have access to a SQL Server database containing over 100,000 records.

Steps to Reproduce Behavior

 * 1) Open a new database in Microsoft Access 97.
 * 2) Link to a SQL Server table that contains at least 100,000 records.
 * 3) Create a query based on the linked table and apply criteria that will reduce the recordset to approximately 25,000 records. Set the sort to Ascending for four of the columns in the query.
 * 4) Run the query.

NOTE: It is important that the query runs for a long time before all the records are returned.
 * 1) While the query is still processing records, use the record number at the bottom of the query window to jump to record number 8040.

NOTE: At this point the complete number of records being returned is not yet displayed. Background processing is still fetching records.
 * 1) Start deleting records, a few at a time.
 * 2) Scroll down a few times (usually 6 or 7 times) using the scroll bar of the query datasheet window.

Within the records you will notice that some of the records are now out of order.

Keywords: kbinterop kbprb KB171178

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.