SQL Server do have some execution statiscs, see sys.dm_exec_query_stats (Transact-SQL)
But not on the level you are looking for, for this you have to implement your own audit/logging.
how to find recently executed queries in a specific database by a specific application?
how to find recently executed queries in a specific database by a specific application?
SQL Server Other
2 answers
Sort by: Most helpful
-
Olaf Helper 47,436 Reputation points
2022-01-12T14:32:14.303+00:00 -
AmeliaGu-MSFT 14,006 Reputation points Microsoft External Staff
2022-01-13T03:02:06.15+00:00 Hi ChaitanyaKiran-2787,
Agree with others. You can select three eventsRPC:Completed, SP:StmtCompleted and SQL:BatchCompleted
in the SQL Server Profiler, and make sure columnApplicationName, DatabaseName and textData
is selected.And then click on the "Column Filters..." button to filter the specific database and application name.
Or you can use Extended event, which is similar with SQL Server profiler. In the new session wizard, select
rpc_completed,sql_batch_complete and sql_batch_starting
events, and make sureclient_app_name, database_name and sql_text
is clicked in “capture Global Fields” page, then filter the database and application name in the “Set Session Event Filters” page.Please refer to Use SQL Server Profiler to trace database calls from third party applications and Quickstart: Extended events in SQL Server which might be helpful.
Best Regards,
Amelia
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.