{"id":883,"date":"2018-10-07T18:33:35","date_gmt":"2018-10-07T11:33:35","guid":{"rendered":"http:\/\/www.sqlservertutorial.net\/?page_id=883"},"modified":"2021-04-28T15:42:46","modified_gmt":"2021-04-28T08:42:46","slug":"sql-server-triggers","status":"publish","type":"page","link":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/","title":{"rendered":"SQL Server Triggers"},"content":{"rendered":"\n<p>SQL Server triggers are special <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-stored-procedures\/\">stored procedures<\/a> that are executed automatically in response to the database object, database, and server events. SQL Server provides three type of triggers:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Data manipulation language (DML) triggers which are invoked automatically in response to <code><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-insert\/\">INSERT<\/a><\/code>, <code><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-update\/\">UPDATE<\/a><\/code>, and <code><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-delete\/\">DELETE<\/a><\/code> events against tables.<\/li><li>Data definition language (DDL) triggers which fire in response to <code><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-create-table\/\">CREATE<\/a><\/code>, <code>ALTER<\/code>, and <code><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-drop-table\/\">DROP<\/a><\/code> statements. <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-ddl-trigger\/\">DDL triggers<\/a> also fire in response to some system stored procedures that perform DDL-like operations.<\/li><li>Logon triggers which fire in response to <code>LOGON<\/code> events<\/li><\/ul>\n\n\n\n<p>In this section, you will learn how to effectively use triggers in SQL Server.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-create-trigger\/\">Creating a trigger in SQL Server<\/a> &#8211; show you how to create a trigger in response to insert and delete events.<\/li><li><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-instead-of-trigger\/\">Creating an INSTEAD OF trigger<\/a> &#8211; learn about the&nbsp;<code>INSTEAD OF<\/code> trigger and its practical applications.<\/li><li><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-ddl-trigger\/\">Creating a DDL trigger<\/a> &#8211; learn how to create a DDL trigger to monitor the changes made to the structures of database&nbsp;objects such as tables, views,&nbsp;and indexes.<\/li><li><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-disable-trigger\/\">Disabling triggers<\/a>&nbsp;&#8211; learn how to disable a trigger of a table temporarily so that it does not fire when associated events occur.<\/li><li><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-enable-trigger\/\">Enabling triggers<\/a>&nbsp;&#8211; show you how to enable a trigger.<\/li><li><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-view-trigger-definition\/\">Viewing the definition of a trigger<\/a> &#8211; provide you with various ways to view the definition of a trigger.<\/li><li><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-list-all-triggers\/\">Listing all triggers in SQL Server<\/a> &#8211; show you how to list all triggers in a SQL Server by querying data from the sys.triggers view.<\/li><li><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-drop-trigger\/\">Removing triggers<\/a> &#8211; guide you how to drop one or more existing trigger.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>SQL Server triggers are special stored procedures that are executed automatically in response to the database object, database, and server events. <\/p>\n","protected":false},"author":1,"featured_media":2739,"parent":0,"menu_order":8,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-883","page","type-page","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL Server Triggers Tutorial<\/title>\n<meta name=\"description\" content=\"SQL Server triggers are special stored procedures that are executed automatically in response to the database object, database, and server events.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Server Triggers Tutorial\" \/>\n<meta property=\"og:description\" content=\"SQL Server triggers are special stored procedures that are executed automatically in response to the database object, database, and server events.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Server Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-28T08:42:46+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/\",\"name\":\"SQL Server Triggers Tutorial\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/sql-server-triggers.svg\",\"datePublished\":\"2018-10-07T11:33:35+00:00\",\"dateModified\":\"2021-04-28T08:42:46+00:00\",\"description\":\"SQL Server triggers are special stored procedures that are executed automatically in response to the database object, database, and server events.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/sql-server-triggers.svg\",\"contentUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/sql-server-triggers.svg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server Triggers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\",\"name\":\"SQL Server Tutorial\",\"description\":\"The Practical SQL Server Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Server Triggers Tutorial","description":"SQL Server triggers are special stored procedures that are executed automatically in response to the database object, database, and server events.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/","og_locale":"en_US","og_type":"article","og_title":"SQL Server Triggers Tutorial","og_description":"SQL Server triggers are special stored procedures that are executed automatically in response to the database object, database, and server events.","og_url":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/","og_site_name":"SQL Server Tutorial","article_modified_time":"2021-04-28T08:42:46+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/","url":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/","name":"SQL Server Triggers Tutorial","isPartOf":{"@id":"https:\/\/www.sqlservertutorial.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/sql-server-triggers.svg","datePublished":"2018-10-07T11:33:35+00:00","dateModified":"2021-04-28T08:42:46+00:00","description":"SQL Server triggers are special stored procedures that are executed automatically in response to the database object, database, and server events.","breadcrumb":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/#primaryimage","url":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/sql-server-triggers.svg","contentUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/sql-server-triggers.svg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlservertutorial.net\/"},{"@type":"ListItem","position":2,"name":"SQL Server Triggers"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlservertutorial.net\/#website","url":"https:\/\/www.sqlservertutorial.net\/","name":"SQL Server Tutorial","description":"The Practical SQL Server Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlservertutorial.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/comments?post=883"}],"version-history":[{"count":1,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/883\/revisions"}],"predecessor-version":[{"id":2755,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/883\/revisions\/2755"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media\/2739"}],"wp:attachment":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media?parent=883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}