Select dbo.ve_GetPathFromContentID(t.Fromid), C.Type FROM [Items] I Join Contents C on C.ContentID = I.ContentID JOIN Transitions t on t.ToID = I.ItemID -- or t.RangeID = I.ItemID WHERE C.Type in (20004, 20005, 20006, 20007, 20008, 20010, 20011, 20019, 20030, 20031, 20035)