Exception calling “InitializeAsReader” in PowerShell Reading Trace Files

Today I needed to process some results files from Distributed Replay to compare before and after metrics from a synchronized replay that I had a client run for testing a change in hardware.  I’ve done this before using PowerShell to automate things and the script for it is pretty simple: However, when I tried to […]

Implicit Conversions that cause Index Scans

Implicit conversions seem to be a growing trend in the SQL Server performance tuning work that I’ve been engaged in recently, and I’ve blogged in the past about ways to identify when implicit conversions are occurring using the plan cache. For those of you who don’t know, implicit conversions occur whenever data with two different […]

The AdventureWorks2008R2 Books Online Random Workload Generator

Over time, I’ve had a number of reasons to need to run a random workload against SQL Server to be able to demonstrate troubleshooting, how SQLOS works, and most recently how to capture a Replay Trace for my series on the Distributed Replay Utility in SQL Server 2012.  For a while I’ve maintained a large […]

Capturing InfoMessage Output (PRINT, RAISERROR) from SQL Server using PowerShell

Tonight, a question was asked on the #sqlhelp tag on Twitter about how to capture all of the output from a stored procedures execution, to include the informational and error message outputs that may be returned by using PRINT or RAISERROR in the code.  This was a problem I ran into in the past with […]

Running Paul’s nonclustered index count survey against multiple instances

Paul put up a new survey today titled Survey: nonclustered index counts (code to run).  If you’d like to run the query for this survey against multiple SQL Servers at once using PowerShell here is the script to do it: # Load the Snapins for SqlServer if they aren’t currently loaded if((Get-PSSnapin -Name SqlServerCmdletSnapin100 -ErrorAction […]

Creating a new Login on Multiple Servers with the same SID using Powershell

Steve Jones (Blog|Twitter) asked a question on the #sqlhelp hash tag tonight that I found interesting so I thought I’d play around with Powershell for a few minutes and see if I could beat Aaron Nelson (Blog|Twitter) to the punch with a Powershell answer for once.  Steve’s question was: @wayoutwest: “Anyone have a PSH script […]

Changing SQL Agent Job Owner with Powershell

This blog post came from a question on the MSDN Forums asking how to change the owner of all SQL Agent Jobs on a server without having to do it manually.  I had to accomplish a similar task in the past, where I needed to scan a list of servers for jobs that were owned […]

Sanitizing Execution Plans using Powershell

A few weeks ago I tweeted a couple of images showing a really nasty execution plan in SQL Sentry’s free Plan Explorer tool being displayed on a 65 inch touch screen LCD monitor.   I’ve been using Plan Explorer to look at execution plans since its early beta’s, when it was known as Plan Viewer, […]

Parsing SQLIO Output to Excel Charts using Regex in PowerShell

Today Joe Webb (Blog|Twitter) blogged about The Power of Regex in Powershell, and in his post he shows how to parse the SQL Server Error Log for events of interest.  At the end of his blog post Joe asked about other places where Regular Expressions have been useful in PowerShell so I thought I’d blog […]