There is a strange problem on some of new upgraded sql server 2012 servers,for example:
use testDB
go
select partition_id,object_id,index_id,partition_number,rows
from sys.partitions
where object_id = object_id ('testtable')
order by index_id
select partition_id,object_id,index_id,partition_number,row_count
from sys.dm_db_partition_stats
where object_id = object_id ('testtable')
order by index_id
-- query results as below
-------------------- ----------- ----------- ---------------- --------------------
72057599707119616 158727718 1 1 3957149
72057599732875264 158727718 2 1 3957149
72057599738642432 158727718 2 1 3950892
72057599389859840 158727718 4 1 3957149
72057599714852864 158727718 11 1 3957149
72057599738707968 158727718 11 1 3950892
72057599736283136 158727718 11 1 3945037
72057599728025600 158727718 31 1 3957149
72057599678808064 158727718 48 1 3957149
partition_id object_id index_id partition_number row_count
-------------------- ----------- ----------- ---------------- --------------------
72057599707119616 158727718 1 1 3957149
72057599732875264 158727718 2 1 3957149
72057599389859840 158727718 4 1 3957149
72057599714852864 158727718 11 1 3957149
72057599728025600 158727718 31 1 3957149
72057599678808064 158727718 48 1 3957149
Index 2 and index 11 index columns are:
indexid 22: Hotel(int), onlineDisplay(char(1)), CloseFlag(char(1))indexid 11: onlineDisplay(char(1)), CloseFlag(char(1)), Room(int), Hotel(int), Currency(char(3)), PrepayReserveType(varchar(5))
So the question are:
1st: Why the two queries got different results?
2nd: Why the two indexes (indexid =2 and indexid=11) have multiple rows from sys.partitions
3rd: And the two indexes (indexid =2 and indexid=11) have different rows?
Many thanks.