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

ID: Q171178


The information in this article applies to:
  • Microsoft Access 97
  • Microsoft SQL Server versions 6.0, 6.5


SYMPTOMS

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

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.


  5. 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.


  6. Start deleting records, a few at a time.


  7. 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 OdbcSqlms
Version : 97
Platform : NT WINDOWS
Issue type : kbprb


Last Reviewed: April 23, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.