Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2017 August SQL Server: How to find Table name from Page ID?

SQL Server: How to find Table name from Page ID?

SQLCorruptData

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

In the previous post, I shared demonstration on how to corrupt your table in SQL Server.

Generally, SQL DBAs are executing DBCC CHECKDB for checking and finding damaged table or data. But if your database size is very enormous and the result of DBCC CHECKDB is also huge, it is tough to find out suspected tables.

Then, what is the solution?
The solution is to check the suspect pages and find the table name using object id.

Check the below demonstration where I used one sample corrupted table, and more you can test the yesterday’s post for tbl_bad.

Check the suspect_pages:

1
SELECT * FROM [msdb].[dbo].[suspect_pages]

Result:

1
2
3
database_id file_id page_id
----------- ----------- --------------------
10 1 312

Execute below DBCC PAGE:
Database id =10
File no=1
Page id=312
Print option=0

1
2
3
4
DBCC TRACEON (3604);
DBCC PAGE (10, 1, 312, 0);
DBCC TRACEOFF (3604);
GO

Result:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
PAGE HEADER:
 
Page @0x000000F815DC4000
 
m_pageId = (1:312) m_headerVersion = 1 m_type = 1
m_typeFlagBits = 0x0 m_level = 0 m_flagBits = 0x8200
m_objId (AllocUnitId.idObj) = 138 m_indexId (AllocUnitId.idInd) = 256
Metadata: AllocUnitId = 72057594046971904
Metadata: PartitionId = 72057594041335808 Metadata: IndexId = 1
Metadata: ObjectId = 565577053 m_prevPage = (0:0) m_nextPage = (0:0)
pminlen = 8 m_slotCnt = 5 m_freeCnt = 7976
m_freeData = 206 m_reservedCnt = 0 m_lsn = (34:228:3)
m_xactReserved = 0 m_xdesId = (0:0) m_ghostRecCnt = 0
m_tornBits = -411585792 DB Frag ID = 1
 
Allocation Status
 
GAM (1:2) = ALLOCATED SGAM (1:3) = NOT ALLOCATED PFS (1:1) = 0x40 ALLOCATED 0_PCT_FULL
DIFF (1:6) = CHANGED ML (1:7) = NOT MIN_LOGGED

Find Metadata: ObjectId and get the object name:

1
SELECT OBJECT_NAME (565577053);

Aug 10, 2017Anvesh Patel
SQL Server: Corrupt a table using DBCC WRITEPAGESQL Puzzle: SQL Advance Query - Find most awarded cricket match type

Leave a Reply Cancel reply

CAPTCHA
Refresh

*

Anvesh Patel
Anvesh Patel

Database Engineer

ImageAugust 10, 2017 SQL ServerAnvesh Patel, database, database research and development, DBCC IND, DBCC PAGE, DBCC TRACEOFF, DBCC TRACEON, dbrnd, Metadata, object id, SQL Query, SQL Server, SQL Server Administrator, SQL Server Error, SQL Server Monitoring, SQL Server Performance Tuning, SQL Server Programming, SQL Server Tips and Tricks, suspect_pages, TSQL
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....