Microsoft KB Archive/240858

= FIX: sp_statistics May Return Incorrect Results After ALTER TABLE DROP COLUMN =

Article ID: 240858

Article Last Modified on 6/1/2006

-

APPLIES TO


 * Microsoft SQL Server 7.0 Standard Edition

-



This article was previously published under Q240858



BUG #: 55811 (SQLBUG_70)

97 (MDAC_QFE)



SYMPTOMS
After dropping a column from a table through ALTER TABLE, attempts to obtain statistics about an index through sp_statistics may return incorrect results. This procedure is used by the Microsoft ODBC driver when an application calls SQLStatistics, and through the Microsoft OLE DB provider for certain queries using IDBSchemaRowset.

You receive incorrect results only when the ordinal of the column you drop is the ordinal of one of the columns in your index. Consider the following example: create table test (c1 int, c2 int, c3 int) create index idx_test on test (c2, c3) create index idx_test2 on test (c3) alter table test drop column c1 exec sp_statistics 'test' After the drop column, the results from sp_statistics fails to indicate that c2 is a part of index idx_test, as well as failing to indicate that c3 is part of index idx_test2. This is because c2 and c3 are both the first column of their respective index, which matches the column ordinal of column c1 that was originally part of the table.

If you run sp_help for the test table, it shows the correct column information for all of the indices.



RESOLUTION
A supported fix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Apply it only to computers that are experiencing this specific problem. This fix may receive additional testing. Therefore, if you are not severely affected by this problem, Microsoft recommends that you wait for the next SQL Server service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

NOTE: In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The typical support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this fix should have the following file attributes or later:   File name -  instcatfix.exe NOTE: Due to file dependencies, the most recent hotfix or feature that contains the above files may also contain additional files.



WORKAROUND
Remove the column by performing a SELECT INTO of the desired columns into a new table, dropping the original table, and then rename the intermediate table to have the original table name. Indexes will also have to be recreated, as permissions may need to be granted as well.

You may also obtain a subset of the information from sp_statistics by running sp_help on the base table.



STATUS
Microsoft has confirmed this to be a problem in SQL Server 7.0.

Additional query words: change modify schema

Keywords: kbbug kbfix kbqfe kbhotfixserver KB240858

-

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

© Microsoft Corporation. All rights reserved.