1

I need your help with a concept I want to show developers, that concept is to help them understand how SQL Server retrieves data from a table.

In the event that a developer does not use a clustered index on a table I want to be able to show them the RID (Row Identification number) SQL Server uses to find the record.

So my question is in a select statement - how do you return the RID?

I know that you can use the following to find where SQL Server stores the data in the data file:

SELECT TOP(100) sys.fn_PhysLocFormatter(%%physloc%%) AS [File:Page:Slot], *
FROM  [dbo].[Badges] ;
SELECT   TOP(100) *
FROM   [dbo].[Badges]
CROSS APPLY sys.fn_PhysLocCracker(%%physloc%%);

My question is:

In a select statement how do you return the RID alongside the table data?

1
  • 5
    your query already returns what is known as the RID or "bookmark" in SQL Server. This is just the File:Page:Slot - there isn't some other number May 26, 2020 at 7:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.