Groups | Blog | Home
all groups > sql server (alternate) > may 2004 >

sql server (alternate) : Disabilitazione trigger [DISABLE TRIGGER]


Pecos Bill
5/7/2004 6:01:11 PM
Salve, non riesco a disabilitare un trigger su sqlserver nè da query
analyzer, nè da enterprise manager.
In pratica tal cosa riuscivo a farla in Oracle con TOAD, mentre qui non
riesco.
Mi interessa disattivarlo senza cancellarlo per poi riattivarlo al bisogno
senza rilanciare lo script di creazione.
Grazie a tutti

Hi I need to disable a DB trigger and I'm not able to do this neither with
query analyzer, neither with enterprise manager.
I remeber this job was quite simple using TOAd in Oracle.
I'm interested in making it disabled not delete it, without run creation
script.

Thanks a lot to everybody.


Erland Sommarskog
5/7/2004 10:20:27 PM
Pecos Bill (pecos.bill@yahoo.it) writes:
[quoted text, click to view]

Ci sono due maniere di fare questo. Il più facile è a usare
ALTER TABLE tbl DISABLE TRIGGER tri. Ma bisogna comprendere che il
trigger è disabiliato per ogni usatori. Il alternativo e usare un
temp tabella, e nel trigger scrivi:

IF object_id('tempdb..#trigger_disabilitato') IS NULL
BEGIN
.. il code del trigger suivi qui.
END

Il tabella non bisogna avere qualche dati, solamente esistere per
disabilitare il trigger.

[quoted text, click to view]

There are two ways to do this. The simplest is to use ALTER TABLE tbl
DISABLE TRIGGER tri. But you need to understand that this disables the
triggers for all users. The alternative is to use a temp table as a flag.
The temp table does not need to have any data, only to exist to disable
the trigger.




--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
Hugo Kornelis
5/7/2004 10:38:57 PM
[quoted text, click to view]

Hi Pecos,

ALTER TABLE MyTable
DISABLE TRIGGER MyTrigger

Best, Hugo
--

Pecos Bill
5/8/2004 5:53:36 AM
thank you very much.
Alessandro

Pecos Bill
5/8/2004 5:54:04 AM
grazie tantissimo.

thanks a lot.

AddThis Social Bookmark Button