Anyway to create a SQL Server DDL trigger for “SELECT” statements?

前端 未结 6 1109
太阳男子
太阳男子 2020-12-03 18:34

I am dealing with some sensitive Accounting tables and I would like to audit any SELECT statement executed on the table or any views associated with them.

6条回答
  •  旧巷少年郎
    2020-12-03 18:57

    CREATE PROCEDURE sp_Product_Select @User_Name VarChar(128), @ID Int AS
    INSERT INTO My_Trace_Table (Table_Name, User_Name, Table_ID, Select_DateTime)
    VALUES ('Products', @User_Name, @ID, GetDate())
    
    SELECT *
    FROM Products
    WHERE ID = @ID
    RETURN
    GO
    

提交回复
热议问题