使用SQL扩展事件捕获链接的服务器查询 [英] Capture Linked server queries using SQL Extended Events
问题描述
我尝试了许多事件类型,但无法实现链接服务器的日志记录.我可以找出所有其他数据库的事件,但是链接服务器没有运气.有什么建议么 ?
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 ?
推荐答案
您可以使用 OLEDB_DATA_READ
事件来跟踪对链接服务器的查询.如果此事件的结果比您想要的更为冗长,则可能需要添加过滤器以捕获所需的特定信息.以下 DDL 创建此扩展事件并可能需要调整选项(即 FILENAME
、MAX_MEMORY
等).
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
这篇关于使用SQL扩展事件捕获链接的服务器查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!