hexedecimal
hexedecimal

Reputation: 299

How to get the complete query that is currently running

I'm trying to get (for debug reasons) the currently running query with the query below :

SELECT sqltext.TEXT,
req.session_id,
req.status,
req.command,
req.cpu_time,
req.total_elapsed_time
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext

With this query, I get the currently running query's but not the complete query because it's cut off when the query is too big.

Is there a way to get the complete query instead of the cut-off version?

Upvotes: 0

Views: 677

Answers (1)

Christian
Christian

Reputation: 5521

You can use the options Results To Text (or Results To File) in the management studio by pressing CTRL + T in the query window.

enter image description here

There is an option to set the maximum number of characters options in tools | Options dialog on the Query Results | SQL Server | Results to Grid page.

enter image description here

Same for results to grid, there it is maximum number of character per row.

enter image description here

Upvotes: 2

Related Questions