Fun with SQL Express


Fun with SQL Express

At work, we use Microsoft’s SQL Server 2005 Express Edition with some of our unit tests. It’s not easy to test code that uses business objects and a persistence framework without some sort of database, and SQL Express allows us to create local database files (test decks) to hold our test data. This works reasonably well, although I learned that creating a separate test deck for each test project adds significant maintenance overhead.

When we started using CruiseControl.NET, though, the tests would often fail to connect to SQL Express. The problem was intermittent.

In the end, I had to automate the following before each batch of tests:

  1. Use NAnt’s servicecontroller task to stop the SQL Express service.
  2. Use Sysinternal’s PsKill to
    terminate the SQL Express process that was sometimes still running after the service was stopped (even after a delay)!
  3. Delete the contents of the SQLEXPRESS settings folder (at C:\Documents and Settings\[user name]\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS, I think - see
  4. Restart the service.

Oh, and since Microsoft took over Sysinternals, you now get a license dialog the first time you run each and every utility (even individual command-line ones). Worse, this is per user. I had to log in as the service account and run PsKill once to agree to the license.

We’re licensed for the full SQL Server. We use many, many licensed Microsoft products at our company. Occasionally we want to use some of their free tools. Does it have to be this hard?

Update - March 25, 2008

That still didn’t resolve the issue completely; one of the test suites failed due to this problem the other night. (It did reduce the frequency of failures.)

Update - March 29, 2008

See the March 29th post.

Your Host:
Copyright © 2000-2013 by William Sorensen. All rights reserved.