Search code examples
sql-serverpermissionsdatabase-permissions

SQL Server Disabling All Triggers - Cannot find the object "XXXX" because it does not exist or you do not have permissions


I'm trying to run this command in SQL Server:

disable trigger all on MYDB

This is failing for me. The account I'm logged into has access to MYDB and I've pretty much giving it every single permission available (it's a local DB and my account only, so this is OK). I don't understand why it's telling me it can't find MYDB for this? I've done this before. Also note: I can select from the database, update, and run a grant statement (such as granting execution of a proc). I can also disable triggers manually...

So why does this fail? I was able to do it before...

Thanks.


Solution

  • sp_msforeachtable 'ALTER TABLE ? DISABLE TRIGGER all'
    

    To enable all triggers, you can use following statement

    sp_msforeachtable 'ALTER TABLE ? ENABLE TRIGGER all'