Capture Linked server queries using SQL Extended Events

混江龙づ霸主 提交于 2021-02-08 05:37:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!