问题
I tried many event types but could not achieve logging for Linked server. I could figure out events for all other databases but no luck with linked server. Any suggestions ?
回答1:
You can use the OLEDB_DATA_READ
event to track queries to linked servers. If the results from this event are more verbose than you want, you may need to add filters to capture the the particular information that is needed. The following DDL creates this extended event and adjusting the options (i.e. FILENAME
, MAX_MEMORY
, etc.) will probably be necessary.
CREATE EVENT SESSION [XE_Linked_Server_Test] ON SERVER
ADD EVENT sqlserver.oledb_data_read
ADD TARGET package0.event_file(SET FILENAME=N'C:\Test\XE_Output_File.xel')
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,
MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF)
GO
来源:https://stackoverflow.com/questions/53323361/capture-linked-server-queries-using-sql-extended-events