--Allow the operation of system tables
Use master
DECLARE @databasename varchar (255)
Set @databasename = ' Blwy BarCode '
--1. If the user library does not start, open the SQL Server Analysis Finder and execute the following command
EXEC sp_configure ' Allow update ', 1 reconfigure with override
--2. Setting up the database to emergency mode
UPDATE sysdatabases set status=-32768 where dbid=db_id (@databasename)
--3. Creating a log file DBCC REBUILD_LOG (@databasename, ' D:\Blwy barcode_log.ldf ')
--4. Modify only allow dbo access to the--sp_dboption @databasename, ' dbo use only ', ' false '
--5. Verifying database consistency
DBCC CHECKDB (@databasename)
--6. The 5th step fails, the
exec sp_dboption @databasename, n ' single ', n ' true '--to place the target data base in single-user mode
DBCC CHECKDB (@databasename, Repair_allow_data_loss)
DBCC CHECKDB (@databasename, Repair_rebuild)
exec sp_dboption @databasename, n ' single ', n ' false '--to set the target data base to multi-user mode
--7. Emergency mode for recovering a database
Update sysdatabases set status=0 where [email protected]
--8. Settings for restoring system table operations
exec sp_configure @databasename, 0 reconfigure with override
Database query or only MDF file information