SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to get the table name from a objectID?


How to get the table name from a objectID?

Author
Message
imran.adam
imran.adam
SSC-Enthusiastic
SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)

Group: General Forum Members
Points: 168 Visits: 115
george sibbald (7/15/2013)
check also the minimum repair level checkdb reports.

If its a non-clustered index that turns out to be corrupted you may be able to just drop and recreate it.

Do you have a clean backup? almost always your best way out of a corruption.


Unfortunately no recent clean backup Sad and ive been i cannot repair as its seriously corrupt

I dont know if its a non-clustered index or table that is corrupted. My strategy as i stated above was to create a new db and script all the objects that are 'good' and not the 'bad' ones. This is why im trying to ascertain the corrupt objects.
george sibbald
george sibbald
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24534 Visits: 13698
the checkdb will give you the corrupted object names

---------------------------------------------------------------------
imran.adam
imran.adam
SSC-Enthusiastic
SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)

Group: General Forum Members
Points: 168 Visits: 115
OK, here is the output from the CHECKDB (i cannot see the objectname?)

Msg 8946, Level 16, State 12, Line 2
Table error: Allocation page (1:28502112) has invalid PFS_PAGE page header values. Type is 0. Check type, object ID and page ID on the page.
Msg 8909, Level 16, State 1, Line 1
Table error: Object ID -25000, index ID 0, page ID (1:28502112). The PageId in the page header = (0:0).
Msg 8909, Level 16, State 1, Line 1
Table error: Object ID -25000, index ID 0, page ID (1:28502112). The PageId in the page header = (0:0).
CHECKDB found 1 allocation errors and 1 consistency errors in table '(Object ID -25000)' (object ID -25000).
Msg 8921, Level 16, State 1, Line 1
CHECKTABLE terminated. A failure was detected while collecting facts. Possibly tempdb out of space or a system table is inconsistent. Check previous errors.
Msg 8998, Level 16, State 1, Line 1
Page errors on the GAM, SGAM, or PFS pages do not allow CHECKALLOC to verify database ID 10 pages from (1:28502112) to (1:28510199). See other errors for cause.
Msg 8998, Level 16, State 1, Line 1
Page errors on the GAM, SGAM, or PFS pages do not allow CHECKALLOC to verify database ID 10 pages from (1:28510200) to (1:28518287). See other errors for cause.
Msg 8998, Level 16, State 1, Line 1
Page errors on the GAM, SGAM, or PFS pages do not allow CHECKALLOC to verify database ID 10 pages from (1:28518288) to (1:28526375). See other errors for cause.
CHECKDB found 3 allocation errors and 0 consistency errors not associated with any single object.
Msg 8909, Level 16, State 1, Line 1
Table error: Object ID 632864, index ID 17051, page ID (1:28510200). The PageId in the page header = (55702:800).
CHECKDB found 1 allocation errors and 0 consistency errors in table '(Object ID 632864)' (object ID 632864).
Msg 8909, Level 16, State 1, Line 1
Table error: Object ID 134676585, index ID 1, page ID (1:28518288). The PageId in the page header = (26880:131072).
CHECKDB found 1 allocation errors and 0 consistency errors in table '(Object ID 134676585)' (object ID 134676585).
CHECKDB found 6 allocation errors and 1 consistency errors in database 'Bon_Live'.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)

Group: General Forum Members
Points: 223622 Visits: 46297
That is corrupt beyond the point of being able to identify objects. You've got fatal metadata corruption and allocation page corruption.
You're going to be very lucky if you get much at all out of that.

Go through the tables one by one (select name from sysobjects where xtype='U'), see if you can generate the script, see if you can select any of the data. I suspect a good number of objects will fail. It will take quite some time.

May be easier just to go back to the last good backup and accept that everything since is lost.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


imran.adam
imran.adam
SSC-Enthusiastic
SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)SSC-Enthusiastic (168 reputation)

Group: General Forum Members
Points: 168 Visits: 115
GilaMonster (7/15/2013)
That is corrupt beyond the point of being able to identify objects. You've got fatal metadata corruption and allocation page corruption.
You're going to be very lucky if you get much at all out of that.

Go through the tables one by one (select name from sysobjects where xtype='U'), see if you can generate the script, see if you can select any of the data. I suspect a good number of objects will fail. It will take quite some time.

May be easier just to go back to the last good backup and accept that everything since is lost.


Many Thanks Gila!

** NOW JUST NEED THE ADMINS TO MOVE THIS THREAD TO THE SQL 2000 FORUM **
Eric B. Webb
Eric B. Webb
Grasshopper
Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)

Group: General Forum Members
Points: 22 Visits: 8
Try this on for size. It will give you the table name base on the object id in the where clause.

SELECT *
FROM sys.objects
WHERE object_id = 632864
GO
--Here's the reverse - to get the Object Id of a known table name. "Department" is the name of the table

SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].department')
GO

You can also use the following code to see if a table exist.

-- this is also good if you need to check is a table exist in SQL
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].department') AND type in (N'U'))
print 'expression is False'
ELSE
PRINT 'expression is TRUE.' ;
Eric M Russell
Eric M Russell
One Orange Chip
One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)

Group: General Forum Members
Points: 28910 Visits: 11495
It sounds like you have data corruption, but you can also try the following to quickly search for an object_id across a multiple databases.

exec sp_MsForEachDB
'
USE ?;
print ''Searching ... ?''
print ''Found: ''+object_name( 632864 );
';


"The universe is complicated and for the most part beyond your control, but your life is only as complicated as you choose it to be."
Bill Talada
Bill Talada
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2918 Visits: 2125
Not sure if you need the structure or the data; ideally you want both of course. I haven't lost data since a sql server 6.5 bad service pack but here is what I did then:

I've had some success rescuing data by using the non-clustered indexes to retrieve it when the clustered index tree is toast. You just need to be smart enough to write the correct WHERE clause and maybe jump over data pages that are bad. Works in a pinch.
Luis Cazares
Luis Cazares
SSC-Forever
SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)

Group: General Forum Members
Points: 41824 Visits: 19815
I really hope the OP didn't depend on the last replies. Not because they're bad, but because it's been over 3 years now.


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
MMartin1
MMartin1
SSCertifiable
SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)

Group: General Forum Members
Points: 7205 Visits: 2033
Luis Cazares (10/12/2016)
I really hope the OP didn't depend on the last replies. Not because they're bad, but because it's been over 3 years now.


I also hope the OP migrated away from SQL Server 2000 and discovered what lead to the massive corruption in the years since.
Though I am curious about one thing, would having log shipping make the data somehow accessible still if one finds themselves in this situation?

----------------------------------------------------
How to post forum questions to get the best help
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search