SQL Server clustered index rebuilds post-transform column location statistics column name unchanged

Source: Internet
Author: User

Originally found using the clustered index primary key, confirming that it is not a primary key problem, is a clustered index problem.

Version:microsoft SQL Server R2 (SP1)


--Create a test table--drop table [testtable]create table [dbo]. [TestTable] ([ID] [int] not null,[name] [varchar] (+) NOT null) go--insert data inserts into [TestTable] ([id],[name]) Select Id%10,left (name, From sys.sysobjectsgo--Create a clustered index ([ID] asc,[name] ASC) Create clustered index [pk_testtable] on [dbo]. [TestTable] ([Id],[name]) go

-- View statistical information
- -DBCC SHOW_STATISTICS (' [dbo].[ TestTable] ', ' pk_testtable ')



Note The order of the red boxes. Now re-create the clustered index

--Delete the clustered index drop INDEX [pk_testtable] on [dbo]. [testtable]go--creates a clustered index ([name],[id]) Create clustered index [pk_testtable] on [dbo]. [TestTable] ([Name],[id]) go


When you delete an index, the statistics are deleted. Now look at the name, the index has been changed to ([Name],[id]), but the statistics show the same column! ~bug?


--and look at statistics DBCC SHOW_STATISTICS (' [dbo].[ TestTable] ', ' pk_testtable ')  


Statistics are normal, except that the column names displayed in the page are not in the same order.

--View index usage, [name] is definitely used index. SELECT * FROM [TestTable] where [id] = 1select * FROM [testtable] where [name] = ' A '


Because it is an index, and can not delete statistics, so also can not change.

This is not a serious problem, but is it strange that these problems can be fixed? Not sure if it's the ssms issue.

In addition to this problem, there is also the function "Update these columns statistics" is also invalid! ~





SQL Server clustered index rebuilds post-transform column location statistics column name unchanged

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.