Query that references the same lookup table twice

  • Hi,

    I am trying to write a query that will access the same table column for lookups twice. In this case there are two columns that reference a serverid column in another table. How can I return the hostname for each column? All of the ways I have tried it end up with the same column in the select list twice.

    Thanks,

    Brian

  • run this in query analyser :

    SELECT DISTINCT Op.name AS ParentObject, Oc.name AS ChildObject

    FROM dbo.sysdepends D INNER JOIN

    dbo.sysobjects Op ON D.id = Op.id INNER JOIN

    dbo.sysobjects Oc ON D.depid = Oc.id

  • Thanks alot!! That looks like what I needed. I will have to save this as a script so that I can look it up when I forget!

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

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