How to get queries executed in Synapse SQL?

Santosh Hegde 21 Reputation points Microsoft Employee
2022-03-28T09:06:11.683+00:00

I need to find all the query executed on my DB in last 1Hr in Synapse workspace with SQL pool. Will apply my logic on top of result set.

What's the right table look for?

  1. sys.dm_exec_requests
  2. sys.dm_exec_requests_history
  3. sys.dm_exec_query_stats
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,373 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. HimanshuSinha-msft 19,486 Reputation points Microsoft Employee Moderator
    2022-03-28T22:09:56.847+00:00

    Hello @Santosh Hegde ,
    Thanks for the question and using MS Q&A platform.
    As we understand the ask here is "How to get queries executed in Synapse SQLin the last hour" , please do let us know if its not accurate.

    You can try out something like below .

    SELECT r.last_execution_time,t.*
    FROM sys.dm_exec_query_stats AS r
    CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) AS t
    where last_execution_time > dateadd(hh,-1,getdate())

    187654-image.png

    Please do let me if you have any queries.
    Thanks
    Himanshu


    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
      • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.