USE adventureworks2014 |

As you can see, the last column represents the record location. However the hexadecimal value is not in a human readable format. To read the physical record of each row in a human readable format, use the following query:
| SELECT * FROM person.addresstype CROSS apply sys.Fn_physloccracker( %% physloc %% ) |

If you are interested in knowing what’s inside the sys.fn_PhysLocCracker function, use sp_helptext as follows:
| EXEC Sp_helptext 'sys.fn_PhysLocCracker' |
which display the definition of sys.fn_PhysLocCracker
-------------------------------------------------------------------------------
-- Name: sys.fn_PhysLocCracker
--
-- Description:
-- Cracks the output of %%physloc%% virtual column
--
-- Notes:
-------------------------------------------------------------------------------
| CREATE FUNCTION sys.Fn_physloccracker (@physical_locator BINARY (8)) returns @dumploc_table TABLE ( [file_id] INT NOT NULL, [page_id] INT NOT NULL, [slot_id] INT NOT NULL ) AS BEGIN DECLARE @page_id BINARY (4) DECLARE @file_id BINARY (2) DECLARE @slot_id BINARY (2) -- Page ID is the first four bytes, then 2 bytes of page ID, then 2 bytes of slot -- SELECT @page_id = CONVERT (BINARY (4), Reverse ( Substring (@physical_locator, 1, 4))) SELECT @file_id = CONVERT (BINARY (2), Reverse ( Substring (@physical_locator, 5, 2))) SELECT @slot_id = CONVERT (BINARY (2), Reverse ( Substring (@physical_locator, 7, 2))) INSERT INTO @dumploc_table VALUES (@file_id, @page_id, @slot_id) RETURN END |
The undocumented sys.fn_PhysLocCracker works on SQL Server 2008 and above.
Years of Experience
Gratified Students
Training Batches
Training Hours
Please subscribe our technical blog to get recent updates.