Sometimes we need to know the file number and page number of a record stored in the table, but after our own query, it is a hexadecimal page number, then how can we calculate the "file number" and "page number" of the Record Based on the hexadecimal page number?
The following functions help us solve this problem: return the [X: XX] format
Alter Function Convert_page_nums ( @ Page_num Binary ( 6 ))
Returns Varchar ( 11 )
As
Begin
Return (
Convert ( Varchar ( 2 ),(
Convert ( Int , Substring ( @ Page_num , 6 , 1 )) * Power ( 2 , 8 )
) +
( Convert ( Int , Substring ( @ Page_num , 5 , 1 )))
) + ' : ' +
Convert ( Varchar ( 11 ),
( Convert ( Int , Substring ( @ Page_num , 4 , 1 )) * Power ( 2 , 24 )) +
( Convert ( Int , Substring ( @ Page_num , 3 , 1 )) * Power ( 2 , 16 )) +
( Convert ( Int , Substring ( @ Page_num , 2 , 1 )) * Power ( 2 , 8 )) +
( Convert ( Int , Substring ( @ Page_num , 1 , 1 )))
)
)
End
Then you can run the following SELECT statement to call this function.
Select DBO. convert_page_nums (0x6e0000000100 );
The following result is displayed: 1: 110
---------------------- End --------------------------