SQL Server filters
Request filters are invoked when a request is received from a database client.
Response filters are invoked when a response is received from the database server.
Duplex filters are invoked in both cases.
Filters are given the opportunity to look at the packet and do whatever they want with it: let it through, modify it, or reject it. Unless it's rejected, the packet is then forwarded to its destination.
Context
All filters define the following variables, which can be accessed from your JavaScript code:
log : A Logger object to output messages to the logging system
context : a container object described in the MSSQL Contexts page
Request filters types
JavaScript request filter : can be invoked for any request from clients.
Login filter: invoked when a login is attempted into the database.
Query filter: can be invoked for SQLBatch packets.
RPC filter: can filter calls to stored procedures
Prepared statement filter: can filter invocations of prepared statements
Bulk load filter: can filter bulk loads issued by the SqlBulkCopy object
Request logging filter: can log any request packets to standard log or to a log file
Response filter types
JavaScript response filter: can be invoked for any response from the database server.
Response logging filter : can log any responses from the database server to a file or to standard out.
Result set filter: can be invoked for every row in a result set, whether from a SQL query or a stored procedure call.
Result set batch filter: can be invoked if the connection is set to batch mode.
Duplex filter types
JavaScript duplex filter: can be invoked for any requests or responses.
Duplex logging filter: can log requests and responses to the standard log or to a file.
Data classification filter: ensures that SQL Server's data classification feature is always available to your filter logic, even if your database clients do not support that feature.
Connection filters are also available if you need to execute logic when a connection is opened or closed.