When I use a script to drop a database and reload the database with updated data, I often get an error message saying that the database is in use. I'm the only user. If I stop and restart the MSSQLServer service, the script works fine. I don't always receive the error message, but after I do, the message appears repeatedly until I reboot or stop and restart the service. How can I avoid this error message?
If you're using SQL Server 2000, try executing the following statement to remove all users from the database:
ALTER DATABASE SET ROLLBACK IMMEDIATE
Make sure you aren't logged in to the database and that you haven't issued a USE <db> command to the database you're trying to load.