sqlservr.exe -m :Default Instance
sqlservr.exe -m -s
When will you start the SQL server instance to the single user mode?
- change server configuration options
- recover a damaged master database or other system database
If you cannot connect to the single mode, it is possible that the SQL Server agent service is running, which uses the single connection.
REPAIR_ALLOW_DATA_LOSS
Database must be in single user mode
ALTER DATABASE AdventureWorks SET SINGLE_USER;
GO
DBCC CHECKDB('database',REPAIR_ALLOW_DATA_LOSS);
GO
--After fixing the database, set it to multi-user mode
ALTER DATABASE AdventureWorks SET MULTI_USER;
GO
When you run DBCC CHECKDB('database',REPAIR_ALLOW_DATA_LOSS) in single user model, it updates the msdb.dbo.SUSPECT_PAGES table.
Procedures of restore a damaged data page:
1.Get the page id from msdb..suspect_pages;
2. Start a page restore with a full database, file, or filegroup backup that contains the page;
RESTORE DATABASE database_name
PAGE = 'file:page [ ,...n ]' [ ,...n ]
FROM
WITH NORECOVERY
3.
Apply the most recent differentials .
Apply the subsequent log backups.
4. Create a new log backup of the database that includes the final log serial number of the restored pages.
5. Restore the new log backup with RECOVERY
Example:
RESTORE DATABASE
RESTORE LOG
RESTORE LOG
BACKUP LOG
RESTORE LOG <
GO
Backup medium not good
RESTORE WITH CONTINUE_AFTER_ERROR
when CONTINUE_AFTER_ERROR is used in RESTORE Statement, Data pages that fail verification will be logged into msdb..SUSPECT_PAGES table.