Logging Schema-changes in a Database using DDL Trigger

Published Dec 02 2020 12:14 PM 2,627 Views
Microsoft

Logging Schema-changes in a Database using DDL Trigger

 

Every so often I have been asked “how it is possible to log and review the audit-logs when Developers change objects but do not have access to the SQL Audit?”.

Now, even a security person like me should try to understand the real motivation for this before jumping to the conclusion that Auditing is the only right solution.

So first let’s understand the potential motivations:

 

What is the purpose?

Very often, the background is simply to keep a record of who changed which database-objects to answer typical question like:

  • “Did anyone change any index lately?”
  • “I thought we had an Index here on this table, did anyone drop it?”
  • “Who changed my procedure?” (Although I would advise to keep a record of all changes within the header of any module as a best practice)
  • “When did the last deployment run/stop?”
  • “My old SQL-Function code is gone; does anyone have a copy?”

The motivation is roughly about troubleshooting schema-changes. The aim is not to detect security breaches or even to support tamper-proof security investigations.

If that is the case, my advice here is to not use Auditing at all for such purpose.
The Auditing feature in SQL Server and Azure SQL Database is really meant to be used by security personae, or Administrators with high privileges:

  • The ability to create change, stop and remove Audits is collected under one permission: either ALTER ANY SERVER AUDIT or ALTER ANY DATABASE AUDIT, depending on the scope.
  • To read the audit result, at a minimum the ALTER ANY SERVER AUDIT-permission is required for Audits to the Application or Security Log but CONTROL SERVER for Audits to a file. In Azure SQL Database CONTROL DATABASE is required when using the system function sys.fn_get_audit_file to read from a File target in Blob Storage. Event Hub or Log Analytics are accessed outside from the SQL engine and not controlled with SQL-permissions.

The above request is much more easily fulfilled with a simple solution that allows the results of the DDL-activities to be stored directly within a database table. This will provide a convenient way to understand what scripts or ad-hoc changes to a database schema happened – but it will not serve as measure against evil actors/attackers.

 

Security-Note
If the requirement is, to provide an Audit trail for Security and Compliance reasons, out of reach for normal Database Developers or anyone accessing SQL Server alone, then SQL Auditing is the right solution. DDL Triggers and local tables can be easily tampered with once an attacker elevated to basic datawriter or ddl_admin-level permissions.

 

The solution

If you need to support your Engineering team with a simple record of all DDL statements (Data Definition Language) run against a database, then I recommend using DDL Triggers.

A DDL Trigger is comparable to a stored procedure except it gets activated when any DDL event for which it was created occurs. The list of Events that can be used is here: DDL Events - SQL Server | Microsoft Docs.

 

Personal experience
Over the years working on customer systems, I personally found it to be invaluable and as best practice equipped any database that I designed with such a small trigger and DDL-log-table, just in case. It has helped many times to quickly solve issues with deployments scripts, non-scripted changes to the systems, problems with Source Control and simply getting answers quickly.
The concept is almost trivial and because DDL changes are usually not in performance-critical code-paths, the theoretical overhead on the DDL statement-runtimes is not relevant. (Unless frequent schema-changes are part of a performance-sensitive workload – in which case I would then question if using DDL is a good idea at all in such a place. By the way: DDL on temporary tables is not caught by DDL Triggers.)

 

If we want to log “almost any DDL statement”, we can use the keyword DDL_DATABASE_LEVEL_EVENTS and then within the body of the trigger we can ignore certain events.

 

Note
Events that typically make sense to ignore are: regular Index Rebuild, Reorganize and Update Statistics – routines.
- Rebuild and Reorganize are both covered by the ALTER_INDEX event. But I would recommend keeping an eye on ALTER INDEX … DISABLE, therefore in my code-example you will find a bit of logic to exclude only ALTER INDEX that is not caused by the DISABLE-option. (“Enable” would be done via a Rebuild, so unfortunately there is a small gap: we will not know when the Index is enabled again. If this turns out to be important, include the Rebuild-option as well, but expect a high volume of events in that case.)

 

Inside the Trigger we have access to the EVENTDATA()-Function which returns the details on the event in xml-format. The trigger-code extracts the most useful data from it.
The so captured events can then be written to a local database table, which is much more convenient for the purpose of troubleshooting than having to go to a Security Audit.

 

Note
If you are interested in the Set-Options used when the command was run (this can be useful for debugging purposes), then the SetOptions-Node below TSQLCommand comes in handy.

 

Finally, we need to make sure that the Trigger will succeed in writing to the table even if the User who triggered the event may not have explicit permissions to write to any table. To keep this example simple my code grants INSERT onto the dedicated table to public. This is the easy way and sufficient for many scenarios. If you need extra security, I recommend using a special account for impersonation during the trigger execution only, using the EXECUTE AS-clause. At the end of the script, you will find an example of how to go about that. That way you can make sure to have least privileges applied and only when really needed.

 

Attached you can find the T-SQL Script which will create the following objects:

  • A Database-Level DDL Trigger
  • A Table in a dedicated Schema
  • A stored procedure to purge data from the table when needed.

Object Explorer with the objects accompanying the triggerObject Explorer with the objects accompanying the trigger

 

Also, I include a Script with some queries to test.

This is how the results in the table look like after running some DDL-commands:

Result tableResult table

 

Documentation-links:

 

I hope you find this script a useful example.

Let me know how you solve similar requirements in the comments below.

Andreas

 

 

%3CLINGO-SUB%20id%3D%22lingo-sub-1950343%22%20slang%3D%22en-US%22%3ELogging%20Schema-changes%20in%20a%20Database%20using%20DDL%20Trigger%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1950343%22%20slang%3D%22en-US%22%3E%3CP%3EEvery%20so%20often%20I%20have%20been%20asked%20%E2%80%9Chow%20it%20is%20possible%20to%20log%20and%20review%20the%20audit-logs%20when%20Developers%20change%20objects%20but%20do%20not%20have%20access%20to%20the%20SQL%20Audit%3F%E2%80%9D.%3C%2FP%3E%0A%3CP%3ENow%2C%20even%20a%20security%20person%20like%20me%20should%20try%20to%20understand%20the%20real%20motivation%20for%20this%20before%20jumping%20to%20the%20conclusion%20that%20Auditing%20is%20the%20only%20right%20solution.%3C%2FP%3E%0A%3CP%3ESo%20first%20let%E2%80%99s%20understand%20the%20potential%20motivations%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1182812560%22%20id%3D%22toc-hId--1182812556%22%3EWhat%20is%20the%20purpose%3F%3C%2FH2%3E%0A%3CP%3EVery%20often%2C%20the%20background%20is%20simply%20to%20keep%20a%20record%20of%20who%20changed%20which%20database-objects%20to%20answer%20typical%20question%20like%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%E2%80%9CDid%20anyone%20change%20any%20index%20lately%3F%E2%80%9D%3C%2FLI%3E%0A%3CLI%3E%E2%80%9CI%20thought%20we%20had%20an%20Index%20here%20on%20this%20table%2C%20did%20anyone%20drop%20it%3F%E2%80%9D%3C%2FLI%3E%0A%3CLI%3E%E2%80%9CWho%20changed%20my%20procedure%3F%E2%80%9D%20(Although%20I%20would%20advise%20to%20keep%20a%20record%20of%20all%20changes%20within%20the%20header%20of%20any%20module%20as%20a%20best%20practice)%3C%2FLI%3E%0A%3CLI%3E%E2%80%9CWhen%20did%20the%20last%20deployment%20run%2Fstop%3F%E2%80%9D%3C%2FLI%3E%0A%3CLI%3E%E2%80%9CMy%20old%20SQL-Function%20code%20is%20gone%3B%20does%20anyone%20have%20a%20copy%3F%E2%80%9D%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThe%20motivation%20is%20roughly%20about%3CSTRONG%3E%20troubleshooting%20schema-changes.%20%3C%2FSTRONG%3EThe%20aim%20is%20%3CSTRONG%3E%3CU%3Enot%3C%2FU%3E%20to%20detect%20security%20breaches%3C%2FSTRONG%3E%20or%20even%20to%20support%20tamper-proof%20security%20investigations.%3C%2FP%3E%0A%3CP%3EIf%20that%20is%20the%20case%2C%20my%20advice%20here%20is%20to%20not%20use%20Auditing%20at%20all%20for%20such%20purpose.%3CBR%20%2F%3EThe%20Auditing%20feature%20in%20SQL%20Server%20and%20Azure%20SQL%20Database%20is%20really%20meant%20to%20be%20used%20by%20security%20personae%2C%20or%20Administrators%20with%20high%20privileges%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20ability%20to%20create%20change%2C%20stop%20and%20remove%20Audits%20is%20collected%20under%20one%20permission%3A%20either%20ALTER%20ANY%20SERVER%20AUDIT%20or%20ALTER%20ANY%20DATABASE%20AUDIT%2C%20depending%20on%20the%20scope.%3C%2FLI%3E%0A%3CLI%3ETo%20read%20the%20audit%20result%2C%20at%20a%20minimum%20the%20ALTER%20ANY%20SERVER%20AUDIT-permission%20is%20required%20for%20Audits%20to%20the%20Application%20or%20Security%20Log%20but%20CONTROL%20SERVER%20for%20Audits%20to%20a%20file.%20In%20Azure%20SQL%20Database%20CONTROL%20DATABASE%20is%20required%20when%20using%20the%20system%20function%20%3CEM%3Esys.fn_get_audit_file%3C%2FEM%3E%20to%20read%20from%20a%20File%20target%20in%20Blob%20Storage.%20Event%20Hub%20or%20Log%20Analytics%20are%20accessed%20outside%20from%20the%20SQL%20engine%20and%20not%20controlled%20with%20SQL-permissions.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThe%20above%20request%20is%20much%20more%20easily%20fulfilled%20with%20a%20simple%20solution%20that%20allows%20the%20results%20of%20the%20DDL-activities%20to%20be%20stored%20directly%20within%20a%20database%20table.%20This%20will%20provide%20a%20convenient%20way%20to%20understand%20what%20scripts%20or%20ad-hoc%20changes%20to%20a%20database%20schema%20happened%20%E2%80%93%20but%20it%20will%20not%20serve%20as%20measure%20against%20evil%20actors%2Fattackers.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CEM%3ESecurity-Note%3C%2FEM%3E%3CBR%20%2F%3EIf%20the%20requirement%20is%2C%20to%20provide%20an%20%3CSTRONG%3EAudit%20trail%20for%20Security%20and%20Compliance%20reasons%3C%2FSTRONG%3E%2C%20out%20of%20reach%20for%20normal%20Database%20Developers%20or%20anyone%20accessing%20SQL%20Server%20alone%2C%20then%20SQL%20Auditing%20is%20the%20right%20solution.%20DDL%20Triggers%20and%20local%20tables%20can%20be%20easily%20tampered%20with%20once%20an%20attacker%20elevated%20to%20basic%20datawriter%20or%20ddl_admin-level%20permissions.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1304700273%22%20id%3D%22toc-hId-1304700277%22%3EThe%20solution%3C%2FH2%3E%0A%3CP%3EIf%20you%20need%20to%20support%20your%20Engineering%20team%20with%20a%20simple%20record%20of%20all%20DDL%20statements%20(Data%20Definition%20Language)%20run%20against%20a%20database%2C%20then%20I%20recommend%20using%20%3CSTRONG%3EDDL%20Triggers%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3EA%20DDL%20Trigger%20is%20comparable%20to%20a%20stored%20procedure%20except%20it%20gets%20activated%20when%20any%20DDL%20event%20for%20which%20it%20was%20created%20occurs.%20The%20list%20of%20Events%20that%20can%20be%20used%20is%20here%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Ftriggers%2Fddl-events%3Fview%3Dsql-server-ver15%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EDDL%20Events%20-%20SQL%20Server%20%7C%20Microsoft%20Docs%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CEM%3EPersonal%20experience%3C%2FEM%3E%3CBR%20%2F%3EOver%20the%20years%20working%20on%20customer%20systems%2C%20I%20personally%20found%20it%20to%20be%20invaluable%20and%20as%20best%20practice%20equipped%20any%20database%20that%20I%20designed%20with%20such%20a%20small%20trigger%20and%20DDL-log-table%2C%20just%20in%20case.%20It%20has%20helped%20many%20times%20to%20quickly%20solve%20issues%20with%20deployments%20scripts%2C%20non-scripted%20changes%20to%20the%20systems%2C%20problems%20with%20Source%20Control%20and%20simply%20getting%20answers%20quickly.%3CBR%20%2F%3EThe%20concept%20is%20almost%20trivial%20and%20because%20DDL%20changes%20are%20usually%20not%20in%20performance-critical%20code-paths%2C%20the%20theoretical%20overhead%20on%20the%20DDL%20statement-runtimes%20is%20not%20relevant.%20(Unless%20frequent%20schema-changes%20are%20part%20of%20a%20performance-sensitive%20workload%20%E2%80%93%20in%20which%20case%20I%20would%20then%20question%20if%20using%20DDL%20is%20a%20good%20idea%20at%20all%20in%20such%20a%20place.%20By%20the%20way%3A%20DDL%20on%20temporary%20tables%20is%20not%20caught%20by%20DDL%20Triggers.)%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20we%20want%20to%20log%20%E2%80%9Calmost%20any%20DDL%20statement%E2%80%9D%2C%20we%20can%20use%20the%20keyword%20DDL_DATABASE_LEVEL_EVENTS%20and%20then%20within%20the%20body%20of%20the%20trigger%20we%20can%20ignore%20certain%20events.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CEM%3ENote%3CBR%20%2F%3E%3C%2FEM%3EEvents%20that%20typically%20make%20sense%20to%20ignore%20are%3A%20regular%20Index%20Rebuild%2C%20Reorganize%20and%20Update%20Statistics%20%E2%80%93%20routines.%3CBR%20%2F%3E-%20Rebuild%20and%20Reorganize%20are%20both%20covered%20by%20the%20ALTER_INDEX%20event.%20But%20I%20would%20recommend%20keeping%20an%20eye%20on%20ALTER%20INDEX%20%E2%80%A6%20DISABLE%2C%20therefore%20in%20my%20code-example%20you%20will%20find%20a%20bit%20of%20logic%20to%20exclude%20only%20ALTER%20INDEX%20that%20is%20not%20caused%20by%20the%20DISABLE-option.%20(%E2%80%9CEnable%E2%80%9D%20would%20be%20done%20via%20a%20Rebuild%2C%20so%20unfortunately%20there%20is%20a%20small%20gap%3A%20we%20will%20not%20know%20when%20the%20Index%20is%20enabled%20again.%20If%20this%20turns%20out%20to%20be%20important%2C%20include%20the%20Rebuild-option%20as%20well%2C%20but%20expect%20a%20high%20volume%20of%20events%20in%20that%20case.)%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EInside%20the%20Trigger%20we%20have%20access%20to%20the%20EVENTDATA()-Function%20which%20returns%20the%20details%20on%20the%20event%20in%20xml-format.%20The%20trigger-code%20extracts%20the%20most%20useful%20data%20from%20it.%3CBR%20%2F%3EThe%20so%20captured%20events%20can%20then%20be%20written%20to%20a%20local%20database%20table%2C%20which%20is%20much%20more%20convenient%20for%20the%20purpose%20of%20troubleshooting%20than%20having%20to%20go%20to%20a%20Security%20Audit.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CEM%3ENote%3C%2FEM%3E%3CBR%20%2F%3EIf%20you%20are%20interested%20in%20the%20Set-Options%20used%20when%20the%20command%20was%20run%20(this%20can%20be%20useful%20for%20debugging%20purposes)%2C%20then%20the%20%3CEM%3ESetOptions%3C%2FEM%3E-Node%20below%20%3CEM%3ETSQLCommand%3C%2FEM%3E%20comes%20in%20handy.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFinally%2C%20we%20need%20to%20make%20sure%20that%20the%20Trigger%20will%20succeed%20in%20writing%20to%20the%20table%20even%20if%20the%20User%20who%20triggered%20the%20event%20may%20not%20have%20explicit%20permissions%20to%20write%20to%20any%20table.%20To%20keep%20this%20example%20simple%20my%20code%20grants%20INSERT%20onto%20the%20dedicated%20table%20to%20public.%20This%20is%20the%20easy%20way%20and%20sufficient%20for%20many%20scenarios.%20If%20you%20need%20extra%20security%2C%20I%20recommend%20using%20a%20special%20account%20for%20impersonation%20during%20the%20trigger%20execution%20only%2C%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Ft-sql%2Fstatements%2Fexecute-as-clause-transact-sql%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EEXECUTE%20AS-clause%3C%2FA%3E.%20At%20the%20end%20of%20the%20script%2C%20you%20will%20find%20an%20example%20of%20how%20to%20go%20about%20that.%20That%20way%20you%20can%20make%20sure%20to%20have%20least%20privileges%20applied%20and%20only%20when%20really%20needed.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAttached%20you%20can%20find%20the%20T-SQL%20Script%20which%20will%20create%20the%20following%20objects%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EA%20Database-Level%20DDL%20Trigger%3C%2FLI%3E%0A%3CLI%3EA%20Table%20in%20a%20dedicated%20Schema%3C%2FLI%3E%0A%3CLI%3EA%20stored%20procedure%20to%20purge%20data%20from%20the%20table%20when%20needed.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22AndreasWolter_1-1606938821774.png%22%20style%3D%22width%3A%20345px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F237396i3AF8C9A1EE840CCC%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22AndreasWolter_1-1606938821774.png%22%20alt%3D%22Object%20Explorer%20with%20the%20objects%20accompanying%20the%20trigger%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EObject%20Explorer%20with%20the%20objects%20accompanying%20the%20trigger%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlso%2C%20I%20include%20a%20Script%20with%20some%20queries%20to%20test.%3C%2FP%3E%0A%3CP%3EThis%20is%20how%20the%20results%20in%20the%20table%20look%20like%20after%20running%20some%20DDL-commands%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22AndreasWolter_2-1606938821801.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F237398i0CC22FED4450662D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22AndreasWolter_2-1606938821801.png%22%20alt%3D%22Result%20table%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EResult%20table%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--502754190%22%20id%3D%22toc-hId--502754186%22%3EDocumentation-links%3A%3C%2FH2%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Ftriggers%2Fddl-triggers%3Fview%3Dsql-server-ver15%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EDDL%20Triggers%20%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Ft-sql%2Ffunctions%2Feventdata-transact-sql%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EEVENTDATA%20(Transact-SQL)%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Ft-sql%2Fstatements%2Fstatements%3Fview%3Dsql-server-ver15%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ETransact-SQL%20statements%20-%20SQL%20Server%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Ft-sql%2Fstatements%2Fexecute-as-clause-transact-sql%3Fview%3Dsql-server-ver15%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EEXECUTE%20AS%20Clause%20(Transact-SQL)%20-%20SQL%20Server%20%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fsecurity%2Fauditing%2Fsql-server-audit-database-engine%3Fview%3Dsql-server-ver15%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ESQL%20Server%20Audit%20(Database%20Engine)%20%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-sql%2Fdatabase%2Fauditing-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20SQL%20Auditing%20for%20Azure%20SQL%20Database%20and%20Azure%20Synapse%20Analytics%20-%20Azure%20SQL%20Database%20%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20hope%20you%20find%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Fgxcuf89792%2Fattachments%2Fgxcuf89792%2FAzureSQLBlog%2F468%2F2%2FDB_Trigger_Log_ddl.zip%22%20target%3D%22_self%22%3Ethis%20script%3C%2FA%3E%20a%20useful%20example.%3C%2FP%3E%0A%3CP%3ELet%20me%20know%20how%20you%20solve%20similar%20requirements%20in%20the%20comments%20below.%3C%2FP%3E%0A%3CP%3EAndreas%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1950343%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22AndreasWolter_3-1606938883739.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F237399i17C3CF835B543184%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22AndreasWolter_3-1606938883739.png%22%20alt%3D%22AndreasWolter_3-1606938883739.png%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3EHow%20to%20use%20DDL%20Triggers%20to%20record%20Database-changes%20in%20a%20table.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1950343%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20SQL%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20SQL%20Database%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20SQL%20Security%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESQL%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Jan 19 2021 10:50 PM
Updated by: