samuelbrody1249
samuelbrody1249

Reputation: 4767

How to view the executed SQL in SSMS

In SequelPro there is a nice feature that will give a log of any statements that the application runs (same with Navicat I believe). For example:

enter image description here

Is there anything similar in SSMS where it can show the queries that the application produces behind the scenes, for example, if I do a "rename table" that it would log something like ALTER TABLE table... ?

Upvotes: 1

Views: 244

Answers (1)

Leon Yue
Leon Yue

Reputation: 16411

Please try the query below, it works in Azure SQL databse:

SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query]
FROM sys.dm_exec_query_stats AS deqs
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
ORDER BY deqs.last_execution_time DESC

It can view all the executed SQL queries in SSMS. It still has some limits but it's the closest answer:

enter image description here

Upvotes: 2

Related Questions