Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 trigger "used" by stored procedures

Author  Topic 

xalien
Starting Member

2 Posts

Posted - 2011-06-17 : 04:40:52
hi all, it is possible to know, using a query on catalog tables which trigger are used(disable trigger/enable trigger) by a stored procedure?
thanks

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-06-17 : 05:08:13
Don't understand what you're asking.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

xalien
Starting Member

2 Posts

Posted - 2011-06-17 : 06:00:06
I would like to document the stored procedures defined on my db, for example I have this procedure

CREATE PROCEDURE [dbo].[usp_deletebwusers]
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DISABLE TRIGGER tr_count_users ON dbo.bwusers;
exec usp_countbwusers
-- Insert statements for procedure here
DELETE FROM BWUSERS WHERE USR_USERID = 'ME' AND USR_APPLID = 'APPL'
ENABLE TRIGGER tr_count_users ON dbo.bwusers;
END

If I execute the following query:

SELECT DISTINCT sd.object_id,
OBJECT_NAME(sd.object_id) as stored_procedure,
type, type_desc,
ReferencedObject = OBJECT_NAME(sd.referenced_major_id),
ReferencedObjectID = sd.referenced_major_id,
is_selected, is_updated, is_select_all
FROM sys.sql_dependencies sd
JOIN sys.objects so ON sd.referenced_major_id = so.object_id
WHERE OBJECT_NAME(sd.object_id) = 'usp_deletebwusers'

I'm able to find:
-the access to BWUSERS table
-the execution of usp_countbwusers
but I've no info about "DISABLE TRIGGER tr_count_users" and "ENABLE TRIGGER tr_count_users"
Go to Top of Page
   

- Advertisement -