Real-Life Example: Tracking Employee Table Changes with Magic Tables

In any real-world business application, maintaining a record of data changes is essential—whether for compliance, auditing, or simply understanding who made what changes and when. While SQL Server provides built-in features like Change Data Capture and Change Tracking, these may not always be enabled or available in all editions. In this post, we’ll walk through a real-life example of how to track changes to an Employees table using Magic Tables in SQL Server trigger. This solution is simple, flexible, and works across all editions of SQL Server. What Is a Magic Table in SQL? A Magic Table in SQL refers to the internal tables— INSERTED and DELETED —that SQL Server makes available during the execution of a TRIGGER . These tables store rows affected by INSERT , UPDATE , and DELETE statements. INSERTED contains the new row versions. DELETED contains the original row versions. You can query these tables inside a trigger to understand how data has changed, enablin...