Hi rgn
I give out this script in our SQL Server Internals Class. It will translate
the First, Root and FirstIAM columns in sysindexes.
- Convert page numbers in sysindexes to decimal form for use
-- with DBCC commands
/* You can modify this code to accept a table name and/or index
name, and then only return the corresponding rows
from sysindexes.
This script is provided 'as-is'
*/
select convert(char(30), name) 'name',
id,
indid,
convert(varchar(2), (convert(int, substring(first, 6, 1)) * power(2, 8)) +
(convert(int, substring(first, 5, 1)))) + ':' +
convert(varchar(11),
(convert(int, substring(first, 4, 1)) * power(2, 24)) +
(convert(int, substring(first, 3, 1)) * power(2, 16)) +
(convert(int, substring(first, 2, 1)) * power(2, 8)) +
(convert(int, substring(first, 1, 1)))) 'first',
first,
convert(varchar(2), (convert(int, substring(root, 6, 1)) * power(2, 8)) +
(convert(int, substring(root, 5, 1)))) + ':' +
convert(varchar(11),
(convert(int, substring(root, 4, 1)) * power(2, 24)) +
(convert(int, substring(root, 3, 1)) * power(2, 16)) +
(convert(int, substring(root, 2, 1)) * power(2, 8)) +
(convert(int, substring(root, 1, 1)))) 'root',
root,
convert(varchar(2), (convert(int, substring(firstIAM, 6, 1)) * power(2, 8))
+ (convert(int, substring(firstIAM, 5, 1)))) + ':' +
convert(varchar(11),
(convert(int, substring(firstIAM, 4, 1)) * power(2, 24)) +
(convert(int, substring(firstIAM, 3, 1)) * power(2, 16)) +
(convert(int, substring(firstIAM, 2, 1)) * power(2, 8)) +
(convert(int, substring(firstIAM, 1, 1)))) 'firstIAM',
firstIAM
from sysindexes
--
HTH
----------------
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com [quoted text, click to view] "rgn" <rgn@discussions.microsoft.com> wrote in message
news:64FC5857-E096-410C-B729-5BC1D599F3A9@microsoft.com...
> Hello All,
>
> Would anyone know how to convert the hexadecimal value of the first & root
> column of the sysindexes table.
>
> I need the decimal equivalent as I would want to use DBCC PAGE to trace
> the Index Pages.
>
> Looks like I'm making a mistake as I get the following error when I
> convert 0x9E0300000100
>
>
> Thanks,
> rgn
>
> DBCC TRACEON(3604)
> GO
> DBCC PAGE(5,1,40451,1)
> GO
>
> Server: Msg 8968, Level 16, State 1, Line 1
> Table error: DBCC PAGE page (1:40451) (object ID 0, index ID 0) is out of
> the range of this database.
> DBCC execution completed. If DBCC printed error messages, contact your
> system administrator.
>