SQL Server 2008 R2 – How to Temporarily Archive Databases

sql serversql-server-2008-r2

I've got a client that has approximately 100 databases across 10 servers. We're attempting to create a standardized process for removing old and unnecessary databases. In the process, we'd like a step where we can temporarily 'archive' a database in case it is still in use. This way, we can easily tell if someone is attempting to access it but can not, and if they are we can turn it back on. Otherwise, we'll remove it.

We have backups, so obviously one option would be to create the backup and delete the database. Then, if it needs to be restored, restore from a backup. However, my client is looking for a simpler method if at all possible.

I've googled for awhile and I can't find any method of temporarily archiving a database in SQL Server. So, I was considering recommending that the client rename the database for approximate a week, and then, depending on the response from clients, delete the database. This method would still include the backups.

My question boils down to: What are the potential pitfalls with temporarily renaming a database? Does SQL Server remove any logins or authentication information when a database is renamed and then renamed back? Does anyone have a more standardized recommendation for this process, or a direction to point me to get me researching further?

Thank you!

Best Answer

To answer your questions first:

What are the potential pitfalls with temporarily renaming a database?

At this scale, it'd be bothersome and just potentially messy to be renaming this many databases multiple times in the case some are needed. It may be a pain cutting off all connections when re-naming and could confuse other users as well.

Does MSSQL remove any logins or authentication information when a database is renamed and then renamed back?

Nope! Not an issue.

Does anyone have a more standardized recommendation for this process, or a direction to point me to get me researching further?

In this case, I'd probably just take the databases OFFLINE temporarily to see if they are needed.

You can do this via the GUI by right-clicking a database, Task -> Take Offline, or via TSQL:

ALTER DATABASE [dbname] SET OFFLINE;

When a database is offline, all connections are closed and no new connections can be made to it. It's quick to bring it back online if required:

ALTER DATABASE [dbname] SET ONLINE;

Plus, when the database is offline it's using less resources than an online database, so it may be better for performance in the mean time as well.