Categories
Software

Recovery Pending

We had a couple of databases stuck in the “Recovery Pending” state. The fix is straightforward:

ALTER DATABASE [DBName] SET EMERGENCY;
GO

ALTER DATABASE [DBName] SET SINGLE_USER
GO

DBCC CHECKDB ([DBName], REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS;
GO 

ALTER DATABASE [DBName] SET MULTI_USER
GO
Categories
Software

SQL Server backup with PowerShell

Create a copy-only backup from PowerShell:

Backup-SqlDatabase -ServerInstance 'SalesServer' -Database 'Sales' -BackupFile 'E:\BAK\Sales_Copy.bak' -CopyOnly