title: How to free up memory used by idle SQL Server databases?
body: <p>We have a SQL Server with a few hundred databases. Many of the databases on that server are used only a few times per week. We have a problem where SQL Server sometimes becomes very slow. When that happens, memory usage indicates 99% and paging happens. In order to work around the problem we scheduled a restart of the SQL service every night to unload all those databases and free up memory.</p>
  
  <p>What is the correct way of freeing up memory used by idle databases without taking the SQL Service down? We would like to automate the unloading of any database that was not accessed in the last 30 minutes.</p>
  
  <p><em>Note: I'm looking for a solution that applies to SQL 2005. However, if there's a feature in SQL 2008 to do that I'd like to know about it.</em></p>