Has anyone here used PowerShell to query SQL Query Plan XML ?

  • Has anyone here used PowerShell to query SQL Query Plan XML ?

    For example, I'm trying to use the Select-Xml approach used in this article:

    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/select-xml?view=powershell-7.3

    But the following returns nothing:

    $Path = "C:\4100858.timeout.sqlplan"
    $XPath = "/ColumnReference"
    Select-Xml -Path $Path -XPath $Xpath | Select-Object -ExpandProperty Node

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • I just export the plan and its consumption statistics from the plan cache.

    1 file with all consumption details, 1 .sqlplan file per plan

     

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Johan Bijnens wrote:

    I just export the plan and its consumption statistics from the plan cache.

    1 file with all consumption details, 1 .sqlplan file per plan

    Yes, we can get plan from either plan cache or QueryStore as text into an XML file - but how would you programmatically extract from specific nodes using PowerShell? I'm wanting to parse the XML for specific information like a list of what indexes or operations are used by the plan.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply