Eliminating a Database-in-Use Error Message During a Reload

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.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish