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

ID: Q240858


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

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 that corrects this problem is now available from Microsoft, but it has not been fully regression tested and should be applied only to systems experiencing this specific problem. If you are not severely affected by this specific problem, Microsoft recommends that you wait for the next SQL Server service pack that contains this fix.

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 on support costs, please go to the following address on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
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.

NOTE: If this product was already installed on your computer when you purchased it from the Original Equipment Manufacturer (OEM) and you need this fix, please call the Pay Per Incident number listed on the above Web site. If you contact Microsoft to obtain this fix, and if it is determined that you only require the fix you requested, no fee will be charged. However, if you request additional technical support, and if your no-charge technical support period has expired, or if you are not eligible for standard no-charge technical support, you may be charged a non-refundable fee.

For more information about eligibility for no-charge technical support, see the following article in the Microsoft Knowledge Base:
Q154871 Determining If You Are Eligible for No-Charge Technical Support


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 version 7.0.

Additional query words: change modify schema

Keywords : SSrvAdmin SSrvGen SSrvProg SSrvStProc SSrvTran_SQL kbbug7.00 kbSQLServ700bug
Version : winnt:7.0
Platform : winnt
Issue type : kbbug


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