Can Azure Function captures changes in multiple tables

Lu Li 31 Reputation points
2024-04-16T01:04:24.88+00:00

Hello,

We need to capture data changes across several tables. However, SQL Triggers appear to support only one table each, and each trigger can only be linked to a single Azure function. Can we combine data change tracking from multiple tables and connect them to a single Azure function?

Thanks in advance,

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,841 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 24,786 Reputation points
    2024-04-16T07:03:11.27+00:00

    Based on this old thread :

    You can develop a time-triggered function to invoke a stored procedure that integrates change tracking data from multiple tables where change tracking is enabled.

    For example, assume change tracking (CT) is activated for the tables Product, Order, and Delivery.

    Create a stored procedure that compiles the data changes from these tables into a JSON-formatted message in one column and the table name in another column. The output of this stored procedure should be organized into a table with two primary columns:

    • ChangeContent: Contains the JSON message detailing the changes.
    • TableName: Identifies the table where the changes occurred.

    Additionally, you might include extra columns like ChangeOperation to describe the type of change (insert, update, delete) if needed.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.