Find out what stored procedure modified a table?

Is there a way to monitor a table for some time and find out which stored procedure modified it?

I figure you can use this to see all refrences...'

USE PDEV

SELECT 
    referencing_object_name = obj.name, 
    referencing_object_type_desc = obj.type_desc, 
    referenced_object_name = referenced_entity_name
FROM 
    sys.sql_expression_dependencies sd 
INNER JOIN 
    sys.objects obj ON sd.referencing_id = obj.[object_id] 
WHERE 
    referenced_entity_name = 'ORDER_DETAIL'

Upvotes: 1

Views: 115

Answers (1)

SQL Police
SQL Police

Reputation: 4196

Yes you can do, but you need to setup SQL Server Auditing.

Read more in the Microsoft documentation. For example, start here: https://learn.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-database-engine?view=sql-server-2017

Upvotes: 3

Related Questions