{"id":980,"date":"2018-10-16T07:46:20","date_gmt":"2018-10-16T00:46:20","guid":{"rendered":"http:\/\/www.sqlservertutorial.net\/?page_id=980"},"modified":"2020-04-11T20:13:05","modified_gmt":"2020-04-11T13:13:05","slug":"sql-server-ddl-trigger","status":"publish","type":"page","link":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-ddl-trigger\/","title":{"rendered":"SQL Server DDL Trigger"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to use the SQL Server data definition language (DDL) trigger to monitor the changes made to the database objects.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='introduction-to-sql-server-ddl-triggers'>Introduction to SQL Server DDL triggers <a href=\"#introduction-to-sql-server-ddl-triggers\" class=\"anchor\" id=\"introduction-to-sql-server-ddl-triggers\" title=\"Anchor for Introduction to SQL Server DDL triggers\">#<\/a><\/h2>\n\n\n\n<p>SQL Server DDL triggers respond to server or database events rather than to table data modifications. These events created by the Transact-SQL statement that normally starts with one of the following keywords <code>CREATE<\/code>, <code>ALTER<\/code>, <code>DROP<\/code>, <code>GRANT<\/code>, <code>DENY<\/code>, <code>REVOKE<\/code>, or <code>UPDATE STATISTICS<\/code>.<\/p>\n\n\n\n<p>For example, you can write a DDL trigger to log whenever a user issues a <code><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-create-table\/\">CREATE TABLE<\/a><\/code> or <code>ALTER TABLE<\/code> statement.<\/p>\n\n\n\n<p>The DDL triggers are useful in the following cases:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Record changes in the database schema.<\/li><li>Prevent some specific changes to the database schema.<\/li><li>Respond to a change in the database schema.<\/li><\/ul>\n\n\n\n<p>The following shows the syntax of creating a DDL trigger:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TRIGGER<\/span> trigger_name\n<span class=\"hljs-keyword\">ON<\/span> { <span class=\"hljs-keyword\">DATABASE<\/span> |  <span class=\"hljs-keyword\">ALL<\/span> <span class=\"hljs-keyword\">SERVER<\/span>}\n&#91;<span class=\"hljs-keyword\">WITH<\/span> ddl_trigger_option]\n<span class=\"hljs-keyword\">FOR<\/span> {event_type | event_group }\n<span class=\"hljs-keyword\">AS<\/span> {sql_statement}\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id='trigger_name'>&nbsp;trigger_name <a href=\"#trigger_name\" class=\"anchor\" id=\"trigger_name\" title=\"Anchor for &nbsp;&lt;code&gt;trigger_name&lt;\/code&gt;\">#<\/a><\/h3>\n\n\n\n<p>Specify the user-defined name of trigger after the <code>CREATE TRIGGER<\/code> keywords. Note that you don&#8217;t have to specify a schema for a DDL trigger because it isn&#8217;t related to an actual database table or view.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='database-all-server'>&nbsp;DATABASE | ALL SERVER <a href=\"#database-all-server\" class=\"anchor\" id=\"database-all-server\" title=\"Anchor for &nbsp;&lt;code&gt;DATABASE | ALL SERVER&lt;\/code&gt;\">#<\/a><\/h3>\n\n\n\n<p>Use <code>DATABASE<\/code> if the trigger respond to database-scoped events or <code>ALL SERVER<\/code> if the trigger responds to the server-scoped events.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='ddl_trigger_option'>&nbsp;ddl_trigger_option <a href=\"#ddl_trigger_option\" class=\"anchor\" id=\"ddl_trigger_option\" title=\"Anchor for &nbsp;&lt;code&gt;ddl_trigger_option&lt;\/code&gt;\">#<\/a><\/h3>\n\n\n\n<p>The <code>ddl_trigger_option<\/code> specifies <code>ENCRYPTION<\/code> and\/or <code>EXECUTE AS<\/code> clause. <code>ENCRYPTION<\/code> encrypts the definition of the trigger. <code>EXECUTE AS<\/code> defines the security context under which the trigger is executed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='event_type-event_group'>&nbsp;event_type | event_group <a href=\"#event_type-event_group\" class=\"anchor\" id=\"event_type-event_group\" title=\"Anchor for &nbsp;&lt;code&gt;event_type | event_group&lt;\/code&gt;\">#<\/a><\/h3>\n\n\n\n<p>The <code>event_type<\/code> indicates a DDL event that causes the trigger to fire e.g., <code>CREATE_TABLE<\/code>, <code>ALTER_TABLE<\/code>, etc.<\/p>\n\n\n\n<p>The <code>event_group<\/code> is a group of <code>event_type<\/code> event such as <code>DDL_TABLE_EVENTS<\/code>.<\/p>\n\n\n\n<p>A trigger can subscribe to one or more events or groups of events.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='creating-a-sql-server-ddl-trigger-example'>Creating a SQL Server DDL trigger example <a href=\"#creating-a-sql-server-ddl-trigger-example\" class=\"anchor\" id=\"creating-a-sql-server-ddl-trigger-example\" title=\"Anchor for Creating a SQL Server DDL trigger example\">#<\/a><\/h2>\n\n\n\n<p>Suppose you want to capture all the modifications made to the database index so that you can better monitor the performance of the database server which relates to these index changes.<\/p>\n\n\n\n<p>First, <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-create-table\/\">create a new table<\/a> named <code>index_logs<\/code> to log the index changes:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> index_logs (\n    log_id <span class=\"hljs-built_in\">INT<\/span> <span class=\"hljs-keyword\">IDENTITY<\/span> PRIMARY <span class=\"hljs-keyword\">KEY<\/span>,\n    event_data <span class=\"hljs-keyword\">XML<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>,\n    changed_by SYSNAME <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>\n);\nGO\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Next, create a DDL trigger to track index changes and insert events data into the <code>index_logs<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TRIGGER<\/span> trg_index_changes\n<span class=\"hljs-keyword\">ON<\/span> <span class=\"hljs-keyword\">DATABASE<\/span>\n<span class=\"hljs-keyword\">FOR<\/span>\t\n    CREATE_INDEX,\n    ALTER_INDEX, \n    DROP_INDEX\n<span class=\"hljs-keyword\">AS<\/span>\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-keyword\">SET<\/span> NOCOUNT <span class=\"hljs-keyword\">ON<\/span>;\n\n    <span class=\"hljs-keyword\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span> index_logs (\n        event_data,\n        changed_by\n    )\n    <span class=\"hljs-keyword\">VALUES<\/span> (\n        <span class=\"hljs-keyword\">EVENTDATA<\/span>(),\n        <span class=\"hljs-keyword\">USER<\/span>\n    );\n<span class=\"hljs-keyword\">END<\/span>;\nGO\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In the body of the trigger, we used the <code>EVENTDATA()<\/code> function that returns the information about server or database events. The function is only available inside DDL or logon trigger.<\/p>\n\n\n\n<p>Then, create indexes for the <code>first_name<\/code> and <code>last_name<\/code> columns of the <code>sales.customers<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> NONCLUSTERED <span class=\"hljs-keyword\">INDEX<\/span> nidx_fname\n<span class=\"hljs-keyword\">ON<\/span> sales.customers(first_name);\nGO\n\n<span class=\"hljs-keyword\">CREATE<\/span> NONCLUSTERED <span class=\"hljs-keyword\">INDEX<\/span> nidx_lname\n<span class=\"hljs-keyword\">ON<\/span> sales.customers(last_name);\nGO\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>After that, query data from the <code>index_changes<\/code> table to check whether the index creation event was captured by the trigger properly:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    *\n<span class=\"hljs-keyword\">FROM<\/span>\n    index_logs;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Here is the output:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"555\" height=\"60\" src=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-DDL-Trigger-Example.png\" alt=\"SQL Server DDL Trigger Example\" class=\"wp-image-982\" srcset=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-DDL-Trigger-Example.png 555w, https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-DDL-Trigger-Example-300x32.png 300w\" sizes=\"auto, (max-width: 555px) 100vw, 555px\" \/><\/figure>\n\n\n\n<p>If you click on the cell of the <code>event_data<\/code> column, you can view XML data of the event as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"553\" height=\"449\" src=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-DDL-Trigger-EventData-XML.png\" alt=\"SQL Server DDL Trigger EventData XML\" class=\"wp-image-985\" srcset=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-DDL-Trigger-EventData-XML.png 553w, https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-DDL-Trigger-EventData-XML-300x244.png 300w\" sizes=\"auto, (max-width: 553px) 100vw, 553px\" \/><\/figure>\n\n\n\n<p>In this tutorial, you have learned how to create a SQL Server DDL trigger that responds to one or more DDL events.<\/p>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"980\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-ddl-trigger\/\"\n\t\t\t\tdata-post-title=\"SQL Server DDL Trigger\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"980\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-ddl-trigger\/\"\n\t\t\t\tdata-post-title=\"SQL Server DDL Trigger\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial explains you the SQL Server data definition language (DDL) trigger and how to use them monitor the changes made to the database objects.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":883,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-980","page","type-page","status-publish","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 DDL Trigger - Learn How To Create DDL Trigger in SQL Server<\/title>\n<meta name=\"description\" content=\"This tutorial explains you the SQL Server data definition language (DDL) trigger and how to use them monitor the changes made to the database objects.\" \/>\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\/sql-server-ddl-trigger\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Server DDL Trigger - Learn How To Create DDL Trigger in SQL Server\" \/>\n<meta property=\"og:description\" content=\"This tutorial explains you the SQL Server data definition language (DDL) trigger and how to use them monitor the changes made to the database objects.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-ddl-trigger\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Server Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2020-04-11T13:13:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-DDL-Trigger-Example.png\" \/>\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=\"3 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\\\/sql-server-ddl-trigger\\\/\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/sql-server-ddl-trigger\\\/\",\"name\":\"SQL Server DDL Trigger - Learn How To Create DDL Trigger in SQL Server\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/sql-server-ddl-trigger\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/sql-server-ddl-trigger\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/SQL-Server-DDL-Trigger-Example.png\",\"datePublished\":\"2018-10-16T00:46:20+00:00\",\"dateModified\":\"2020-04-11T13:13:05+00:00\",\"description\":\"This tutorial explains you the SQL Server data definition language (DDL) trigger and how to use them monitor the changes made to the database objects.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/sql-server-ddl-trigger\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/sql-server-ddl-trigger\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/sql-server-ddl-trigger\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/SQL-Server-DDL-Trigger-Example.png\",\"contentUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/SQL-Server-DDL-Trigger-Example.png\",\"width\":555,\"height\":60,\"caption\":\"SQL Server DDL Trigger Example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/sql-server-ddl-trigger\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server Triggers\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-triggers\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"SQL Server DDL Trigger\"}]},{\"@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 DDL Trigger - Learn How To Create DDL Trigger in SQL Server","description":"This tutorial explains you the SQL Server data definition language (DDL) trigger and how to use them monitor the changes made to the database objects.","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\/sql-server-ddl-trigger\/","og_locale":"en_US","og_type":"article","og_title":"SQL Server DDL Trigger - Learn How To Create DDL Trigger in SQL Server","og_description":"This tutorial explains you the SQL Server data definition language (DDL) trigger and how to use them monitor the changes made to the database objects.","og_url":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-ddl-trigger\/","og_site_name":"SQL Server Tutorial","article_modified_time":"2020-04-11T13:13:05+00:00","og_image":[{"url":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-DDL-Trigger-Example.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-ddl-trigger\/","url":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-ddl-trigger\/","name":"SQL Server DDL Trigger - Learn How To Create DDL Trigger in SQL Server","isPartOf":{"@id":"https:\/\/www.sqlservertutorial.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-ddl-trigger\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-ddl-trigger\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-DDL-Trigger-Example.png","datePublished":"2018-10-16T00:46:20+00:00","dateModified":"2020-04-11T13:13:05+00:00","description":"This tutorial explains you the SQL Server data definition language (DDL) trigger and how to use them monitor the changes made to the database objects.","breadcrumb":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-ddl-trigger\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-ddl-trigger\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-ddl-trigger\/#primaryimage","url":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-DDL-Trigger-Example.png","contentUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-DDL-Trigger-Example.png","width":555,"height":60,"caption":"SQL Server DDL Trigger Example"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/sql-server-ddl-trigger\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlservertutorial.net\/"},{"@type":"ListItem","position":2,"name":"SQL Server Triggers","item":"https:\/\/www.sqlservertutorial.net\/sql-server-triggers\/"},{"@type":"ListItem","position":3,"name":"SQL Server DDL Trigger"}]},{"@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\/980","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=980"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/980\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/883"}],"wp:attachment":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media?parent=980"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}