
DECLARE @ids TABLE ([Id] uniqueidentifier NOT NULL)

INSERT INTO @ids (Id)
SELECT TOP 10
    Objects_Ir_Rel_tbl.IrId
   FROM
    Objects_tbl WITH (nolock)
    INNER JOIN Objects_Ir_Rel_tbl WITH (nolock) ON (Objects_tbl.Id = Objects_Ir_Rel_tbl.ObjectId)
   WHERE
     Objects_tbl.ObjectClass='DS'
 -- AND Objects_tbl.ProcStateColRf = 'N'
 AND Objects_tbl.ProcStateColRf = 'N'
 AND Objects_tbl.ObjectFromSiteID = 'TCP010'
 AND Objects_tbl.ObjectOwningSiteID= 'TCP010' -- 'TCT'
 AND Objects_tbl.ObjectUgMaster_Type = 'SP'
 AND Objects_tbl.ObjectType IN ('UGMASTER','UGPART')
ORDER BY  Objects_tbl.ObjectLastModDate DESC

SELECT Objects_Ir_Rel_tbl.*
  FROM Objects_Ir_Rel_tbl WITH (nolock)
  WHERE EXISTS (SELECT 1 FROM @ids WHERE id=Objects_Ir_Rel_tbl.IrId)
