Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List of Tables used in all the Triggers

Status
Not open for further replies.

manmaria

Technical User
Joined
Aug 8, 2003
Messages
286
Location
US
Is there a way to identify the list of tables used in all the triggers?

TIA
 
I think this will work

select distinct x.name from sysobjects x
inner join
(
select a.name, b.text
from sysobjects a inner join syscomments b
on a.id = b.id

where a.xtype = 'TR'
) z
on charindex(x.name, z.text) > 0
and x.xtype = 'U'
 
You should be able to use the sysdepends table to identify dependencies as in this query.
Code:
SELECT DISTINCT triggername = trg.name, tblname = tbl.name
FROM sysobjects trg
JOIN sysdepends dep
	ON trg.id = dep.id
JOIN sysobjects tbl
	ON dep.depid = tbl.id
WHERE trg.type = 'tr'
ORDER BY 1,2

Terry L. Broadbent - DBA

"The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. (Nathaniel Borenstein)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top