This includes installation prompts for pending operations, shrinking the database, compressing the database, transferring the database to new users for existing user rights, checking backup sets, repairing databases, and so on.
(i) Suspend operation
When installing a SQL or SP patch, the system prompts for a pending installation operation, requiring a reboot, where it is often useless to restart, the solution:
To HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
Delete PendingFileRenameOperations
(ii) Shrinking of the database
--Rebuilding indexes
DBCC REINDEX
DBCC INDEXDEFRAG
--Shrink data and logs
DBCC SHRINKDB
DBCC SHRINKFILE
(iii) Compressed database
dbcc shrinkdatabase(dbname)
(iv) Transfer of the database to new users with existing user rights
exec sp_change_users_login ’update_one’,’newname’,’oldname’
go
(v) Checking backup sets
RESTORE VERIFYONLY from disk=’E:\dvbbs.bak’
(vi) repair of the database
ALTER DATABASE [dvbbs] SET SINGLE_USER
GO
DBCC CHECKDB(’dvbbs’,repair_allow_data_loss) WITH TABLOCK
GO
ALTER DATABASE [dvbbs] SET MULTI_USER
GO
--CHECKDB has 3 parameters:
--REPAIR_ALLOW_DATA_LOSS
--Perform all repairs performed by repair_rebuild, including assigning and unassign rows and pages to correct assignment errors, structural rows or pages, and deleting corrupted text objects. These fixes can cause some data loss. A repair operation can be completed under a user transaction to allow the user to roll back the changes. If you roll back the repair, the database will still contain errors and should be recovered from the backup. If an incorrect fix is omitted due to the level of repair provided, any fixes that depend on the repair will be omitted. After the repair is complete, back up the database.
--repair_fast for small, time-consuming fixes, such as fixing additional keys in a nonclustered index. These fixes can be done quickly, and there is no risk of losing data.
--repair_rebuild performs all the repairs performed by Repair_fast, including the need for a longer period of repair, such as rebuilding an index. There is no risk of losing data when performing these repairs.
--DBCC CHECKDB(’dvbbs’) with NO_INFOMSGS,PHYSICAL_ONLY