You could assign a row number to your results, then show every Xth record from that result. You do this by calculating the total number of records, and dividing that by your desired number of intervals. If the modulo is 0, spit out that record.
In my example below, I want to 10 records (approx) from the sysobjects table, sorted alphabetically by name. The result is 10 records.
This was a lot harder to explain than to write.
;with SummaryTable as
(
select row_number() over (order by name) as RowNum,
name,
(select count(*) from sys.objects) as 'TotalCount'
from sys.objects
)
select *
from SummaryTable
where RowNum % (TotalCount / 10) = 0
Given that this is an internal system table that you can only access when connecting via the DAC, no, there is no documentation on this. What are you using this table for?
I found several instances here where rscolid
was not identical to hbcolid
. For example:
SELECT rsid, rscolid, hbcolid
FROM sys.sysrscols
-- WHERE rscolid <> hbcolid
WHERE rsid = 72057594038714368;
rsid rscolid hbcolid
----------------- ------- -------
72057594038714368 4 2
Where does this row come from?
SELECT OBJECT_NAME(object_id)
FROM sys.partitions
WHERE partition_id = 72057594038714368;
-------------------------
queue_messages_1003150619
So what indexes might be involved?
SELECT index_id, name
FROM sys.indexes
WHERE object_id = OBJECT_ID('sys.queue_messages_1003150619');
index_id name
-------- ---------------------
1 queue_clustered_index
2 queue_secondary_index
So going on a guess, I ran this query:
SELECT
ic1.index_id,
c.name,
ic1.column_id, -- column id in the table
ic1.key_ordinal -- column order in the index
FROM sys.all_columns AS c
INNER JOIN sys.index_columns AS ic1
ON c.[object_id] = ic1.object_id
AND c.column_id = ic1.column_id
AND ic1.column_id <> ic1.key_ordinal
WHERE c.object_id = OBJECT_ID('sys.queue_messages_1003150619');
One of the rows here:
index_id name column_id key_ordinal
-------- --------------------- --------- -----------
1 conversation_group_id 4 2
So, without doing much more investigation, my initial guess is that rscolid
is the column id within the base table, and hbcolid
is the ordinal position of that column in the index. This holds true for 5 of the columns in the clustered index of this queue table - they all have identical mismatches in sys.sysrscols
, and also for one of the columns in the non-clustered index.
But again, whether I'm right or wrong, I'm not sure what you could possibly do with that information: what are you using this table for?
Best Answer
Its an underlying table for sys.partitions, which returns the same information as
SELECT * FROM sys.partitions
Refer to Partitioned Tables and Indexes on MSDN.
idmajor
is the column name that's commonly known asobject_id
idminor
is the index_id.Lets do some testing now: I have used AdventureWorks 2012 from CodePlex.
Lets query the
sys.partitions
view now:If we look at the
sys.indexes
view:SELECT object_id, name, index_id from sys.indexes where object_id = '1237579447'
In the above output, index_id is just an id for the indexes. 1 for Clustered index and the others (2-7) for other non clustered indexes.
Lets take a look at the
sys.sysrowsets
table:I used the object_id for the
HumanResources.Employee
table to filter data.Output:
From this its clear that
object_id
oridmajor
is the same for the table and all the indexes under it andidminor
is nothing but theindex_id
for an index.