question

nidheesh.r.pillai avatar image
nidheesh.r.pillai asked

What are Database Triggers?

On exploring the SQL Server 2008 instance inside SSMS, under the "Programmabilty" node, one would find a folder/node called "Database Triggers". I am curious to know the following- 1. What are Database Triggers? 2. What is the purpose of "Database Triggers" in SSMS, when you cannot even try to create one by doing a "right-click" to the module? 3. How are "Database Triggers" module different from the "Triggers" module that you find under each "Table" node inside SSMS?
sql-server-2008database-triggers
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Kev Riley avatar image
Kev Riley answered
Database triggers are DDL triggers - in that they fire on an action that affects the database structure rather than on data > Server-scoped DDL triggers appear in the SQL Server Management Studio Object Explorer in the Triggers folder. This folder is located under the Server Objects folder. Database-scoped DDL Triggers appear in the **Database Triggers** folder. This folder is located under the Programmability folder of the corresponding database. You can create DDL triggers just like DML triggers - see [CREATE TRIGGER (Transact-SQL)][1] - but if you don't have the right permissions.... > To create a DDL trigger with server scope (ON ALL SERVER) or a logon trigger requires CONTROL SERVER permission on the server. To create a DDL trigger with database scope (ON DATABASE) requires ALTER ANY DATABASE DDL TRIGGER permission in the current database. Read more here : [DDL Triggers][2] [1]: https://msdn.microsoft.com/en-GB/library/ms189799.aspx [2]: https://msdn.microsoft.com/en-GB/library/ms175941.aspx
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.