Use of DBCC PAGE
One more undocumented command is DBCC PAGE. Use it to read the content of database MDF and LDF files.
To find the table page which you would like to read use, DBCC IND and in SQL 2012 onwards - sys.dm_db_database_page_allocations.
Example as below:
Or, we can use the DBCC SEMETADATA('Objectname') command, syntax as below:
So now lets assume, you would like to view the page 165, syntax as below:
One more undocumented command is DBCC PAGE. Use it to read the content of database MDF and LDF files.
NAME: DBCC PAGE
FUNCTION:
Prints out the contents of a SQL Server page.
SYNTAX:
DBCC PAGE ( {'dbname' | dbid}, filenum, pagenum [, printopt={0|1|2|3} ])
PARAMETERS:
Dbid or dbname - Enter either the dbid or the name of the database
in question.
Filenum- Enter the file number, 1- mdf & 2- ldf
Pagenum - Enter the page number of the SQL Server page that is to
be examined.
Print option - (Optional) Print option can be either 0, 1, or 2.
0 - (Default) This option causes DBCC PAGE to print
out only the page header information.
1 - This option causes DBCC PAGE to print out the
page header information, each row of information
from the page, and the page's offset table. Each
of the rows printed out will be separated from
each other.
2 - This option is the same as option 1, except it
prints the page rows as a single block of
information rather than separating the
individual rows. The offset and header will also
be displayed.
3- This option gives in brief info about the page.
Before running this command, you should first set the trace flag by executing command DBCC TRACEON(3604) and then DBCC PAGE('dbname', pagenum, pageid, )To find the table page which you would like to read use, DBCC IND and in SQL 2012 onwards - sys.dm_db_database_page_allocations.
Example as below:
DBCC IND('mydb1',EMPLOYEE,1) GO
Or, we can use the DBCC SEMETADATA('Objectname') command, syntax as below:
Use myDb1 Go DBCC SEMETADATA(N'Employee') GO
So now lets assume, you would like to view the page 165, syntax as below:
DBCC PAGE('mydb1', 1,165,3 ) GoFor more details refer this Article
Nice Article !
ReplyDeleteReally this will help to people of SQL Server Community.
I have also prepared small note on this, Find page informration using DBCC PAGE, DBCC IND of SQL Server.
http://www.dbrnd.com/2016/04/sql-server-dbcc-page-and-dbcc-ind-to-find-a-data-page-information/
Thanks Anvesh!!
DeleteI'm glad, this helps you.
Keep in touch.