Существует вероятность, что ваша проблема может быть решена с помощью SQL Server Audit .
SET NOCOUNT ON;
GO
SELECT @@version;
GO
USE AdventureWorks2016CTP3;
GO
IF EXISTS(SELECT *
FROM sys.database_audit_specifications
WHERE [name] = 'SelectFromPassword') BEGIN
ALTER DATABASE AUDIT SPECIFICATION SelectFromPassword WITH (STATE = OFF);
DROP DATABASE AUDIT SPECIFICATION SelectFromPassword;
END;
GO
USE master;
GO
IF EXISTS(SELECT *
FROM sys.server_audits
WHERE [name] = 'MyServerAudit') BEGIN
ALTER SERVER AUDIT MyServerAudit WITH (STATE = OFF);
DROP SERVER AUDIT MyServerAudit;
END;
GO
-- Create the server audit.
CREATE SERVER AUDIT MyServerAudit TO FILE(FILEPATH = 'D:\MyServerAudit');
GO
-- Enable the server audit.
ALTER SERVER AUDIT MyServerAudit WITH (STATE = ON);
GO
USE AdventureWorks2016CTP3;
GO
-- Create the database audit specification.
CREATE DATABASE AUDIT SPECIFICATION SelectFromPassword
FOR SERVER AUDIT MyServerAudit
ADD (SELECT ON OBJECT::Person.[Password] BY public)
WITH (STATE = ON);
GO
EXECUTE AS LOGIN = 'zanjato';
GO
USE AdventureWorks2016CTP3;
GO
SELECT * FROM Person.[Password];
GO
REVERT;
GO
WAITFOR DELAY '00:00:02';
GO
SELECT
event_time,
server_principal_name,
database_principal_name,
action_id,
database_name,
schema_name,
[object_name],
[statement]
FROM fn_get_audit_file('D:\MyServerAudit\MyServerAudit*',NULL, NULL)
WHERE succeeded = 0;
GO
ALTER DATABASE AUDIT SPECIFICATION SelectFromPassword WITH (STATE = OFF);
GO
DROP DATABASE AUDIT SPECIFICATION SelectFromPassword;
GO
USE master;
GO
ALTER SERVER AUDIT MyServerAudit WITH (STATE = OFF);
GO
DROP SERVER AUDIT MyServerAudit;
Вывод:
-------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2016 (SP1-CU4) (KB4024305) - 13.0.4446.0 (X64)
Jul 16 2017 18:08:49
Copyright (c) Microsoft Corporation
Developer Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 <X64> (Build 9600: ) (Hypervisor)
Changed database context to 'AdventureWorks2016CTP3'.
Changed database context to 'master'.
Changed database context to 'AdventureWorks2016CTP3'.
Changed database context to 'AdventureWorks2016CTP3'.
Msg 229, Level 14, State 5, Line 41
The SELECT permission was denied on the object 'Password', database 'AdventureWorks2016CTP3', schema 'Person'.
event_time server_principal_name database_principal_name action_id database_name schema_name object_name statement
--------------------------- --------------------- ----------------------- --------- ---------------------- ----------- ----------- -------------------------------
2019-02-12 13:28:48.1177803 zanjato zanjato SL AdventureWorks2016CTP3 Person Password SELECT * FROM Person.[Password]
Changed database context to 'master'.