Importance Of ObjectId

  • I have search this topic on internet. But the way of explanation has being too far of expert level. I would like to know the importance of objectid. I have quite often seen this thing being used in queries related to fetching some system related data. I would like to know

    1.What is importance of objectid

    2.What is objectid

    3.Why should we used objectid.

  • It's just an identifier value that's used throughout the system tables. Much like you might create a product table with a productID column and use the productID in related tables.

    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
  • sys.objects - SQL Server 2008 R2

    object_id is a column in the sys.objects catalog view and uniquely identifies an object in the current database. In other words the object_id for a table named dbo.MyTable in Database1 will be different than the object_id for a table named dbo.MyOtherTable in Database1. Similarly, the object_id for dbo.MyTable in Database1 will likely be different than the object_id for a table with the same name in a different database since the pool of object_id's is managed at the database level.

    sys.objects holds references to many different types of database objects. In the link I posted look for the column type_desc.

    There are other catalog views that describe particular types of objects more specifically than the information you can find in sys.objects. For example run this in your database:

    SELECT * FROM sys.tables;

    This describes tables much more deeply than sys.objects.

    Then pick one of the object_id values and run this:

    SELECT * FROM sys.objects WHERE object_id = the_id_picked_from_sys.tables;

    There are many other catalog views that make sue of object_id. sys.objects is the main view. Here is a data map in case you want to do a deep dive on catalog views. Loko for the 'Objects' section in the top left: SQL Server 2008 System Views Map

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply