Reputation: 2886
I have table with update cursor which do not allow me to do bulk updates on it, but need to do some periodical bulk updates (query in sql job). To do this I want to disable cursor in code (disabling trigger in SSMS can ends with timeout error), but when disabling in query runs until I stop it.
Can I somehow set timeout for disabling trigger in query code (or set timeout for job run)? Thanks
Upvotes: 2
Views: 3507
Reputation: 5313
Another option might be to use CONTEXT_INFO. This allows you to set a sort of global variable that is scoped to the current request. Before executing the bulk update you can set the CONTEXT_INFO to a specific value. The trigger can check for this value and skip execution. This way you don't have to disable the trigger.
Upvotes: 3
Reputation: 238086
You could make disabling and re-enabling the trigger part of the transaction. Then if the update query times out, the disabling of the trigger will be rolled back too.
Upvotes: 3