• You should add a check for AutoStats. If you set the database to single user and AutoStats gets started you may have problems regaining access. I used a similar approach to merge two databases into one (at 100+ customer sites) and I did run into the problem.

    Also, IMHO if you do this often enough to justify writing a stored procedure then you really should have a lot more error checking built into the code.