this is a very basic load tester. it basicaly lets you from the command line specify what command to run, how many times, against what connection string and whether you want to see any results. obviously, you can tweak it to print the results differently as you see fit, currently it just spits out field numbers and a value.

here's the code:

using System;
using System.Threading;
using System.Data.SqlClient;
using System.IO;

namespace TestSQL
{
    class Program
    {
        private static string s;
        private static string cs;
        private static int m;
        private static int a;
        private static int n;
        private static bool b;
        static void Main(string[] args)
        {
           
// appname sqlfile threads connectionstring showresults
            // TestSql.exe file.sql 100 "server=x;database=x;user=x" true
            s = new StreamReader(args[0]).ReadToEnd();
            m = Int32.Parse(args[1]);
            cs = args[2];
            b = bool.Parse(args[3]);

            for (int i=0; i < m; i++)
            ThreadPool.QueueUserWorkItem(new WaitCallback(DoSQL), i);

            ThreadPool.GetMaxThreads(out m, out n);
            ThreadPool.GetAvailableThreads(out a, out n);

            while (a != m){
                Thread.Sleep(1000);
                ThreadPool.GetMaxThreads(out m, out n);
                ThreadPool.GetAvailableThreads(out a, out n);
            }
        }
        static void DoSQL(object t)
        {
            Console.WriteLine("start thread#" + t);
            using (SqlConnection c = new SqlConnection(cs)){
                c.Open();
                using (SqlCommand cmd = new SqlCommand(s, c))
                    using (SqlDataReader r = cmd.ExecuteReader()){
                        if(b)
                            while(r.Read())
                                for(int i = 0; i < r.FieldCount;i++)
                                    Console.WriteLine("field #" + i + " = " + r[i]);
                        Console.WriteLine("end thread#" + t);
                    }
            }
        }
    }
}


sample command line syntax:

TestSQL.exe c:\test\t.sql 100 "server=localhost;database=zipcode;integrated security=sspi;Pooling=False;connect timeout=0;" false

i used the same tsql in the t.sql file that i used in this post.