IT Knowledge Base

Technical Repository

HowTo: SQL Server 2008/2012 – Determining how long a database will be in RECOVERY

If you SQL Server crashed in the middle of a transaction, you can use the following queries to get a rough idea as to how much time is left in the RECOVERY stage before the database is consistent again. DECLARE @DBName VARCHAR(64) = ‘databasename’ DECLARE @ErrorLog AS TABLE([LogDate] CHAR(24), [ProcessInfo] VARCHAR(64), [TEXT] VARCHAR(MAX)) INSERT INTO […]

Read More

HowTo: Force a SQL Server Database Offline

I ran into a problem where I needed to restore a database from backup but was unable to take the database offline due to existing connections. The task would just stay there processing and after an hour, I had enough. I wanted to force the database to go offline regardless of any connections so I […]

Read More