48,757 Members
6 added today
405,217 Resources
187 added today

All Devdex   All Gurus  

Data page structure and dbcc page
Author: Nigel Rivett
Rating: Rate this Resource
Visits: 3065

Discuss in Newsgroups

Page:

-- Data page structure and dbcc page.
Author Nigel Rivett

This is a method of retrieving the the data page which stores the data in a table.
It can sometimes be useful to see what effect an operation has on the physical storage structures.
It gives the usage of "dbcc page", how to decifer first in sysindexes to obtain data page and the format of the page.

-- create a table to test with
create table test (s char(10), t varchar(10))
insert test select 'abc', 'def'
insert test select 'ghi', 'jkl'
insert test select 'ghi', null

/*
Now read the data page.
format for dbcc page is
dbcc page (dbname/id, file number, page number, option) - option = 2 for headers
the file number and page number for the table can be found from column "first" in the root entry in sysindexes.
*/
select * from sysindexes where id = object_id('test') and indid in (1,0)
/*
first = 0xB64738000100
the first four bytes are the page numver - the last two the file number
These entries are byte reversed and must be converted to integers for the dbcc page command
so
PageNum = 003847B6
FileNum = 0001
*/

declare @first binary(6)
select @first = first from sysindexes where id = object_id('test') and indid = 0
declare @PageNum int
select @PageNum = convert(int, substring(@first,4,1) + substring(@first,3,1) + substring(@first,2,1) + substring(@first,1,1) )
declare @FileNum int
select @FileNum = convert(int, substring(@first,6,1) + substring(@first,5,1))
select @FileNum, @PageNum

/*
now we can run the dbcc page command to get the data page of the table.
*/
declare @sql varchar(1000)
select @sql = 'dbcc page (''' + db_name() + ''', ' + convert(varchar(10),@FileNum) + ', ' +  convert(varchar(10),@PageNum) + ', 2)'
select @sql
dbcc traceon(3604)
exec (@sql)


Next Page >>

Visitor Comments

Be the first to rate this article!

 

Rate this Article







	
	
	



Credit Card Payment Control
Supports over 25 companies
Managed ASP.NET Solution
Direct Processor Support

ASP ArticlesThis category has been added to your weekly newsletter
ASP Web Sites
ADSI & WSH BooksThis category has been added to your weekly newsletter
FREE ComponentsThis category has been added to your weekly newsletter
ASP EventsThis category has been added to your weekly newsletter
ASP HeadlinesThis category has been added to your weekly newsletter

CSharp ArticlesThis category has been added to your weekly newsletter
C# Web SitesThis category has been added to your weekly newsletter

SQL ArticlesThis category has been added to your weekly newsletter
SQL Events
SQL HeadlinesThis category has been added to your weekly newsletter
SQL Jobs

Jobs in CaliforniaThis category has been added to your weekly newsletter

XML ArticlesThis category has been added to your weekly newsletter
XML BooksThis category has been added to your weekly newsletter
XML Web Sites
XML Tutorials

free asp host

"Alex Homer"This search has been added to your weekly newsletter

Edit My Favorites Edit Profile & Favorites

Web Programming

 




Developersdex Home | ASP | C# | SQL | VB | XML | Gurus
Add Your Link | Add Your Code | FAQ | Advertise | Link To Us | Contact Us |
Copyright © 2009 Developersdex™. All rights reserved.