Thanks that is what I was looking for, I was just looking in the ALTER TRIGGER 
section of the BOL, not the ALTER TABLE.

-----Original Message-----
From: Neil Robertson-Ravo [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 09, 2005 1:49 PM
To: SQL
Subject: Re: Temporarily Disabling a Trigger


We normally usa a UDF (you can use Enterprise Manager if you want quick 
n dirty)cto disable triggers - though to be honest we hardly use them as 
there is rarely a need these days.

NOTE: You can also do it with straight SQL:

ALTER TABLE yourtable DISABLE TRIGGER yourknowntrigger

Here is the UDF
===========
IF (OBJECT_ID ('dbo.GetTriggerStatus') IS NOT NULL)
   DROP FUNCTION dbo.GetTriggerStatus
GO
CREATE FUNCTION dbo.GetTriggerStatus (@tcTableName SYSNAME)
   RETURNS TABLE AS
   RETURN
   (
      SELECT
         name,
         status = CASE WHEN OBJECTPROPERTY (id, 'ExecIsTriggerDisabled') = 0
            THEN 'Enabled' ELSE 'Disabled' END,
         owner = OBJECT_NAME (parent_obj)
      FROM
         sysobjects
      WHERE
         type = 'TR' AND
         parent_obj = CASE WHEN @tcTableName IS NULL THEN parent_obj 
ELSE OBJECT_ID (@tcTableName) END
   )
GO



and can be called thus;

SELECT * FROM dbo.GetTriggerStatus ('yourtable')  
-- or table name can be Null.


HTH

N



>  
>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:6:2338
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/6
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:6
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.6
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to