Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 956
Brian Mains Avatar asked Aug 24 '11 14:08

Brian Mains


People also ask

How can I see all triggers in SQL Server?

To view database level triggers, Login to the server using SQL Server management studio and navigate to the database. Expand the database and navigate to Programmability -> Database Triggers. To view triggers at the server level, Login to Server using SSMS and navigate to Server Objects and then Triggers folder.

How do I mask a string in SQL?

Use a combination of STUFF , REPLICATE and CHARINDEX . CHARINDEX will give you the position of a particular string inside another one (the first by default). REPLICATE will repeat a string N amount of times, we use this for the mask.


1 Answers

sp_msforeachtable 'ALTER TABLE ? DISABLE TRIGGER all' 

To enable all triggers, you can use following statement

sp_msforeachtable 'ALTER TABLE ? ENABLE TRIGGER all' 
like image 155
Derek Kromm Avatar answered Sep 18 '22 07:09

Derek Kromm