FIX: ORDER BY Queries May Remove Spaces from ANSI_PADDING Tables

ID: Q189343


The information in this article applies to:
  • Microsoft SQL Server version 6.5

BUG #: 18018 (SQLBUG_65)

SYMPTOMS

An ORDER BY query can remove any trailing spaces if all of the following conditions are true:

  • The table is created while ANSI_PADDING is enabled.
  • Some of the rows contain trailing spaces in columns of type varchar.
  • The ORDER BY query is executed with ANSI_PADDING disabled.
  • A worktable is used for an ORDER BY clause.
  • The entire column list is not selected with "*".


WORKAROUND

To work around this problem, try one of the following:

  • Enable ANSI_PADDING before running the query.
  • Create an index on the table that can be used for the ORDER BY clause.
  • Select all columns of the table with "*".


STATUS

Microsoft has confirmed this to be a problem in SQL Server version 6.5. This problem has been corrected in U.S. Service Pack 5a for Microsoft SQL Server version 6.5. For information about downloading and installing the latest SQL Server Service Pack, see http://support.microsoft.com/support/sql/.

For more information, contact your primary support provider.


MORE INFORMATION

DB-Library clients are susceptible to this problem, because ANSI_PADDING is disabled by default. ODBC-based clients would not normally see this problem because ANSI_PADDING is enabled by default.

Additional query words: sp sp5sort truncate truncated work table

Keywords : SSrvProg kbbug6.50 kbfix6.50.SP5
Version : winnt:6.5
Platform : winnt
Issue type : kbbug


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