Monday, June 23, 2014

Shrink Database fails with Error: Backup, file manipulation operations

Sometimes you may get below error while trying to shrink their databases manually or using SSMS.

Executing the query "DBCC SHRINKDATABASE(N'DemoDate', 10, TR..." failed with the following error: "Backup, file manipulation operations (such as ALTER DATABASE ADD FILE) and encryption changes on a database must be serialized.

Probable reason for above error:

While shrink Database backup is running. You cannot do below operation while doing backup:

• The file truncation phase of shrink database or shrink file.

• File management operations such as the ALTER DATABASE statement with either ADD FILE or REMOVE FILE clauses.

Please note that if backup is running and one of the above operations is attempted, then operation fails immediately. When user is trying to add or remove a file and if backups is started then backup will wait for a timeout period, then fail.

If user is trying to shrink database or file while a backup is running, the shrink stops without truncating the file. If backup started after shrink database operation then backup waits for shrink operation to complete.


Step 1 : Execute the below T-sql

SELECT session_id, Text FROM sys.dm_exec_requests cross apply sys.dm_exec_sql_text(sql_handle)

If it shows any back up device on the query result, Kill the session ID

Step 2 : If the session ID is 54 then , use the below statement

KILL 54

Now start the backup.

If still its not working, Close all SQL SERVER instance then open a SQL SERVER and do the BACKUP.