THE SQL Server Blog Spot on the Web

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

Adam Machanic

Adam Machanic, Boston-based SQL Server developer, shares his experiences with programming, monitoring, and performance tuning SQL Server. And the occasional battle with the query optimizer.

SQLQueryStress: The Source Code

Back in 2006, I created a very simple tool called SQLQueryStress. The goal of this tool was to enable the user to test a single query under some form of load -- up to 200 simultaneous threads.

I wrote this tool primarily for a book I was working on at the time, and used it for most of the examples therein. And after that, truth be told, I decided that the tool was not very useful. I use it for demos in almost every presentation I give -- it's great for showing simple contention scenarios -- but I can't say that I've used it even a single time in an actual work project.

Interestingly, although I personally haven't found much use for it, many of you out there seem to have. The tool has become incredibly popular over time, and I've received numerous e-mails over the years requesting features, as well as many from people requesting and even offering to pay for the source code.

I've never said yes to any of these source code requests. For a long time I said no because I thought I might add more features and turn SQLQueryStress into something I could sell. Later, as my C# skills improved, I realized that the project was not very well done, and I really didn't want to release garbage code with my name on it. Still later, I thought I'd lost the source code forever in a hard drive crash. Meanwhile, SQLQueryStress has limped along unchanged, even as the wish list has continued to grow.

Things changed last week, when I allowed one of my domains to expire; the one hosting SQLQueryStress. The domain was hosted by a very shady company that I'd long since decided to stop doing business with, and I found myself faced with the task of transferring things to a new provider. That is of course not a big deal, but I decided that the world would be better off without the current version of SQLQueryStress being quite so available. Almost 10 years after its creation -- most of the work done over a long weekend -- the world needs a better tool. I think it's time for someone to step up and deliver. And that someone is not going to be me.

After the domain expired I went searching through my archives and found the source code. I took a quick look and confirmed what I thought all along: It's pretty bad. But today I'm releasing it for free, and the old adage stands: You get what you pay for!

So here's the official word: The attached source code is hereby released to the world, copyright and royalty free. You may use it, if you like, for whatever you want. Enjoy! If you use it for a public project, I would appreciate a mention in the acknowledgements section, but even that is not required. This source code is yours, warts and all. I was tempted to do some cleanup work, but at this point it's just not something I'm ever going to touch again. I upgraded the project from Visual Studio 2005 to Visual Studio 2013, confirmed that it builds and seems to work, and that's that.

I would very much like for someone to release a quality and modern stress tool. I would personally trash this source code and start with something brand new, but if you do use my code or even just my ideas as the base, here are the current top to-do items:

  • Fix bug where SQLQueryStress tends to crash after the Stop button is hit. Some variable, I guess, is not being properly reset.
  • Implement a better query editor. The control I used is bare bones to the max and does no one any favors.
  • Apparently there are some bugs around the statistics creation options not getting properly turned off when you turn them off.
  • Enable more than 200 simultaneous threads. This was just an arbitrary number and can be changed by simply modifying the appropriate control. But perhaps there is a smarter way to come up with a maximum?
  • Implement support for saving of statistics and collected information, and reporting on that data, especially when the same test is run more than once.
  • Implement support for multiple test queries.

If you have any questions about the source code... you're out of luck. I haven't looked at it in at least 8 years. So fire up your debuggers!

And finally, kindly let me know of any public projects you create, so that I can become an end user.

Published Monday, January 4, 2016 10:17 AM by Adam Machanic




ErikEJ said:

How about having the source hosted on Github - I would be happy to offer to do that, and coordinate any bugfixing efforts from the community?

January 4, 2016 11:10 AM

Adam Machanic said:


Sure, you can put it on Github. You can do quite literally whatever you want with it. You do not need to ask my permission :-)


January 4, 2016 11:15 AM

ErikEJ said:

The source is now on Github: - and 6 issues are logged - bring on the Pull Requests!

January 4, 2016 11:22 AM

Yaroslav said:

I'm one of those users that use it often on work related stuff. Comes very handy for testing a bunch of queries with some parameters and get quick results to compare. Hope that releasing it will have a good impact on it and improve it even more. Thanks for this amazing tool.

January 4, 2016 3:00 PM

John Sterrett said:


I just wanted to thank you again for writting SQLQueryStress.  I have used it all the time. I look forward to looking at the source code.



January 8, 2016 10:41 AM

Damian said:

Adam, thanks for sharing the code!

January 12, 2016 12:47 PM

retracement said:

Use this frequently over the years for demos (since I first saw you use it during your precon at PASS Summit in 2010) so it will be interesting seeing what this might morph into. Thanks for releasing the source!

January 19, 2016 3:52 AM

Manohar Punna said:

I used it quiet often. I tried in the past to use it to test connection pooling behavior and wanted to control connection pooling and query timeout. I tried to build console applications for this but no where close to what your tool is. Releasing the sourcecode helps a lot. Thanks a ton for this Adam. Really appreciate your efforts.

January 21, 2016 3:52 PM

Sam said:

Is this website intentionally left in the source code?

January 22, 2016 11:34 AM

Adam Machanic said:


That was the download site, until I let it expire. As mentioned, I didn't modify anything in the source code. Does that make it an intentional inclusion? I'm not sure. In any case, it's your source code now, not mine, so feel free to rip it out.


January 22, 2016 11:40 AM

Sam said:

Just didn't know if were trying to direct us to that ad farm or not... it said click for more, and like a fool, that's what i did.

January 22, 2016 11:54 AM

Adam Machanic said:

Run Ghostery and you won't see anything there :-)

January 22, 2016 2:39 PM

jeff said:

Where can I find an executable for this project?

March 29, 2016 2:05 PM

Void said:


Just compile-it

March 30, 2016 1:31 PM

Adam Machanic said:

@jeff Agreed with Void.

Also, please check out the GitHub version as it has some fixes.


March 30, 2016 3:05 PM

Jeff said:

Tried compiling but was giving some error, am not a visual dev and have no idea about it. would be good if there is an executable which we can just download and use.

March 30, 2016 5:33 PM

Void said:

i can buildit for you. if you whant.

April 7, 2016 9:45 AM

Justin said:

Ok, I'm an do I compile this thing?

July 20, 2016 10:01 AM

Adam Machanic said:


If you have Visual Studio (you can download it for free), you just go to the Build menu and click Build Solution.

You should probably download the latest code from Erik's Github repo, referenced above.


July 20, 2016 12:51 PM

Markus said:

Thank you for sharing with us!

August 8, 2016 11:32 AM

sateesh said:

Thank you Adam for sharing this

October 12, 2016 11:27 PM

Alisa,Qiu said:


I download the zip file and extract it, but I don't know how to use it. There is no .exe file, and I tried to double click the other files they couldn't open the main screen. Could someone tell me how to open this tool? Thanks a lot!

October 23, 2016 10:33 PM

Adam Machanic said:

October 24, 2016 8:55 AM

Jedi said:


Could you recommend any other commercial tool for stress testing a SQL Server (2012, 2016)? SQL Server is on a VM in the cloud. Assuming bandwidth is not an issue, which tool/s can one use to simulate a real-life situation of thousands of transactions per minute, for example?



February 6, 2017 2:00 PM

Jthalliens said:


First of all thanks for sharing this great tool for SQL testing, I've been using it on my demos and test our SQL environment in order to get metrics for IO and CPU but I'm curious about the fact that the tool does not show metrics when temp tables are used within the code I mean does not show IO reads for those temp tables but for worktables, is there any reason why? just for curiosity, I was using to compare the values

Thanks Adam, again great job

May 4, 2017 9:53 AM

Adam Machanic said:


No clue! Maybe the parser has a bug? The wonderful thing about open source is you can debug it, fix it, push it back into the project, and everyone else can benefit. So that's my recommendation for you :-)


May 4, 2017 3:47 PM

jthalliens said:

Sure, I already have a fix for this, it's a minor bug on the application reason why #temp IO reads are not reflected, I'll be pushing the code to the project.

May 7, 2017 12:25 PM

Joe Smart said:

That will be nice to have. Thanks @ Adam Mechanic.

Please i have a quick question what could be responsible for a low utilisation of CPU

and slow SQL execution.

May 15, 2017 11:41 AM

jthalliens said:

Hi All,

The latest build for the application has been released by @ErikEJ which contains changes related to IO reads on Temp and Global Temp tables.

May 15, 2017 2:54 PM

abhishek said:

I am unable to download the SQLQueryStress exe anywhere . Can anyone help ?

June 2, 2017 3:12 AM

George Walkey said:

How to connect on a Non-standard port

colon or comma or non possible?




August 1, 2017 9:12 AM
New Comments to this post are disabled

About Adam Machanic

Adam Machanic is a Boston-based SQL Server developer, writer, and speaker. He focuses on large-scale data warehouse performance and development, and is author of the award-winning SQL Server monitoring stored procedure, sp_WhoIsActive. Adam has written for numerous web sites and magazines, including SQLblog, Simple Talk, Search SQL Server, SQL Server Professional, CoDe, and VSJ. He has also contributed to several books on SQL Server, including "SQL Server 2008 Internals" (Microsoft Press, 2009) and "Expert SQL Server 2005 Development" (Apress, 2007). Adam regularly speaks at conferences and training events on a variety of SQL Server topics. He is a Microsoft Most Valuable Professional (MVP) for SQL Server, a Microsoft Certified IT Professional (MCITP), and an alumnus of the INETA North American Speakers Bureau.

This Blog


Privacy Statement