Sitemap

Full query text…

2 min readOct 31, 2021

--

If you have ever queried the DMV’s (dynamic management views) in Azure Synapse Dedicated Pools / Azure SQL Data Warehouse… SQLDW to its friends… You are able to see a whole range of information, including the SQL (text or command) that was executed.

There has been a tiny snag, these fields are truncated to 3999 characters. Most of time, this is not an issue, but there are times when it would be really useful to see exactly what’s being executed without having to go back to the source system.

Get Mark Pryce-Maher’s stories in your inbox

Join Medium for free to get updates from this writer.

Recently sys,dm_pdw_exec_requests has been updated to contain the full SQL!! There is a new field “command2” — this holds the entire SQL command!!!

Press enter or click to view image in full size
Example of command2

As per the example above, command is still limited to 3999 characters (this is for backwards compatibility). Command2 is empty/null until the SQL text goes over the 3999 limit. If you just want the SQL text no matter how long then something like isnull(command2,command) will do the job nicely.

This is great news for anyone like me who works with very long SQL!!

I have put some examples together on my github.

But be careful the SQL (text or command) from other DMV’s like sys.dm_pdw_request_steps and sys.dm_pdw_sql_requests have not been updated, so you still only see 3999/4000 characters.

--

--

Mark Pryce-Maher
Mark Pryce-Maher

Written by Mark Pryce-Maher

I'm a Senior Program Manager at Microsoft, I work on the Data warehouse in Fabric, it includes Mirroring, MDSync and other stuff.