THE SQL Server Blog Spot on the Web

Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | |
in Search

Rob Farley

- Owner/Principal with LobsterPot Solutions (a MS Gold Partner consulting firm), Microsoft Certified Master, Microsoft MVP (SQL Server), APS/PDW trainer and leader of the SQL User Group in Adelaide, Australia. Rob is a former director of PASS, and provides consulting and training courses around the world in SQL Server and BI topics.

PowerShell to fetch a SQL Execution Plan

Hi! - Great that you've found this page, but it's no longer here! You can find the content over at: http://blogs.lobsterpot.com.au/2010/12/07/powershell-to-fetch-a-sql-execution-plan/

Published Tuesday, December 7, 2010 12:14 PM by Rob Farley

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

SQLvariant said:

This is Excellent Rob.  Thanks for throwing it together!!

December 6, 2010 8:31 PM
 

Rob Farley said:

SQL Server is quite remarkable in a bunch of ways. In this post, I’m using the way that the Query Optimizer

January 3, 2011 12:55 AM
 

juerg said:

Hi

thanks for the script, however e.g. trying to get the plan for AdventureWorks2012.dbo.uspGetBillOfMaterials I get

Error: "Unexpected end of file has occurre

d. The following elements are not closed: OutputList, RelOp, QueryPlan, StmtSimple, Statements, Stor

edProc, StmtSimple, Statements, Batch, BatchSequence, ShowPlanXML. Line 1, position 4001."

At D:\Projekte\Wincasa\QVReporting_home\CreateExecutionPlan.ps1:6 char:109

+ { return ([xml] (invoke-sqlcmd -Server $server -Database $db -Query "set showplan_xml on;`ngo`n$qu

ery").Item <<<< ( 0)) }

   + CategoryInfo          : NotSpecified: (:) [], RuntimeException

   + FullyQualifiedErrorId : RuntimeException

any idea?

Thanks

November 4, 2012 11:11 AM
 

Rob Farley said:

Hi juerg,

Make sure the file contains the right combinations of brackets, braces and parentheses, and has no extra characters in there.

Rob

November 13, 2012 5:46 AM
 

Rob Farley said:

A couple of years I ago I was going to write a song about automation, in reggae style, which could maybe

January 13, 2014 7:08 PM
 

Rob Farley said:

Oh Juerg,

The error you got is just because the plan is larger than the 4000 characters that are being returned. If you use "-MaxCharLength 9999999" this should work better.

Rob

February 17, 2014 12:43 AM

Leave a Comment

(required) 
(required) 
Submit

This Blog

Syndication

Tags

No tags have been created or used yet.

News

News? Haven't you read my blog?

My Company


Can't find something?

Contact Me

IM: rob_farley@hotmail.com
Twitter: @rob_farley
Skype: rob_farley
E: rob_farley@hotmail.com

MVP (SQL Server)




Certifications








Adelaide SQL UG

Privacy Statement