When threads run amuck.

 Sometimes more isn't always better. I ran into a situation where the number of threads being spawned for a particular process was clogging up the server. The machine this query was running on had 16-cpus running sql server 2005 with 16GB of memory, far from a slouch. I fired up this query and did a quick check of the active processes to find over 40 threads attached to these processes. To add to this I had 8 of these queries going. I figured this would be great, parallel processing, I should be done in no time at all. Well...not quite. I ran into an error at night: