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 Journeyman
SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)

Group: General Forum Members
Points: 94 Visits: 115
Hi

I am trying to find the name of a table in our database given a objectID, when i run this

select *
from sysobjects
where id = 632864

I get no records returned. any ideas?

I have got the objectID from

Table error: Object ID 632864, index ID 17051, page ID (1:28510200). The PageId in the page header = (55702:800)

Thanks
John Mitchell-245523
John Mitchell-245523
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13926 Visits: 15926
The object ID is only unique within each database. Are you sure you're querying the correct database? By the way, sysobjects is only included for backward compatibility. You should use sys.objects instead.

John
GilaMonster
GilaMonster
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86292 Visits: 45232
You've got database corruption.

The table name will be printed as part of the CheckDB output. Please run the following and post the full and complete output.

DBCC CHECKDB (<Database Name>Wink WITH NO_INFOMSGS, ALL_ERRORMSGS



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


george sibbald
george sibbald
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10236 Visits: 13687
select OBJECT_NAME(632864)

---------------------------------------------------------------------
imran.adam
imran.adam
SSC Journeyman
SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)

Group: General Forum Members
Points: 94 Visits: 115
george sibbald (7/15/2013)
select OBJECT_NAME(632864)


Sorry that did not work, it came back with NULL
imran.adam
imran.adam
SSC Journeyman
SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)

Group: General Forum Members
Points: 94 Visits: 115
GilaMonster (7/15/2013)
You've got database corruption.

The table name will be printed as part of the CheckDB output. Please run the following and post the full and complete output.

DBCC CHECKDB (<Database Name>Wink WITH NO_INFOMSGS, ALL_ERRORMSGS





Sorry i forgot to mention i am using SQL 2000. so sys.objects is not valid. Yes i am querying the correct DB
GilaMonster
GilaMonster
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86292 Visits: 45232
2000 questions should go in the SQL 2000 forums.

You have database corruption, so that object id is very likely invalid, especially given the nonsensical index id listed (max index id is 255)

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 Journeyman
SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)

Group: General Forum Members
Points: 94 Visits: 115
GilaMonster (7/15/2013)
2000 questions should go in the SQL 2000 forums.

You have database corruption, so that object id is very likely invalid, especially given the nonsensical index id listed (max index id is 255)


Im sorry for posting in the incorrect forum Crying

I am aware i have database corruption, i am trying to script all the objects that are good and leave all the corrupted tables (i am aware that i will lose data). So i was trying to find out where this corrupted table is.

That line i posted above is from the CHECKDB i ran earlier, i will post the complete output in a moment
george sibbald
george sibbald
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10236 Visits: 13687
imran.adam (7/15/2013)
george sibbald (7/15/2013)
select OBJECT_NAME(632864)


Sorry that did not work, it came back with NULL


it would work for a valid id. Just wanted to show you a quick way to resolve it. It proves that that object_id is not valid in your database. run checkdb as gail suggests

---------------------------------------------------------------------
george sibbald
george sibbald
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10236 Visits: 13687
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.

---------------------------------------------------------------------
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