Capture Linked server queries using SQL Extended Events



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















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 ?










share|improve this question






























    1















    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 ?










    share|improve this question


























      1












      1








      1








      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 ?










      share|improve this question
















      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 ?







      sql-server linked-server extended-events






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 16:09









      jarlh

      30.2k52138




      30.2k52138










      asked Nov 15 '18 at 16:02









      Amit BhoyarAmit Bhoyar

      635115




      635115






















          1 Answer
          1






          active

          oldest

          votes


















          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:TestXE_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





          share|improve this answer























          • Hey, thanks for replying, its working. only problem is its creating multiple(20+) rows for single query. Any idea ?

            – Amit Bhoyar
            Nov 19 '18 at 21:03











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323361%2fcapture-linked-server-queries-using-sql-extended-events%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          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:TestXE_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





          share|improve this answer























          • Hey, thanks for replying, its working. only problem is its creating multiple(20+) rows for single query. Any idea ?

            – Amit Bhoyar
            Nov 19 '18 at 21:03















          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:TestXE_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





          share|improve this answer























          • Hey, thanks for replying, its working. only problem is its creating multiple(20+) rows for single query. Any idea ?

            – Amit Bhoyar
            Nov 19 '18 at 21:03













          1












          1








          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:TestXE_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





          share|improve this answer













          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:TestXE_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






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 '18 at 20:40









          userfl89userfl89

          3,5191516




          3,5191516












          • Hey, thanks for replying, its working. only problem is its creating multiple(20+) rows for single query. Any idea ?

            – Amit Bhoyar
            Nov 19 '18 at 21:03

















          • Hey, thanks for replying, its working. only problem is its creating multiple(20+) rows for single query. Any idea ?

            – Amit Bhoyar
            Nov 19 '18 at 21:03
















          Hey, thanks for replying, its working. only problem is its creating multiple(20+) rows for single query. Any idea ?

          – Amit Bhoyar
          Nov 19 '18 at 21:03





          Hey, thanks for replying, its working. only problem is its creating multiple(20+) rows for single query. Any idea ?

          – Amit Bhoyar
          Nov 19 '18 at 21:03



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323361%2fcapture-linked-server-queries-using-sql-extended-events%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Use pre created SQLite database for Android project in kotlin

          Darth Vader #20

          Ondo