Which locks are acquired during database restore

Chaitanya Kiran 656 Reputation points
2023-10-31T15:47:43.3366667+00:00

Which lock does SQL Server place during database restore

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
11,632 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 49,051 Reputation points
    2023-10-31T15:51:42.24+00:00

    none really, the database is basically in single user mode, only the restore has access.

    0 comments No comments

  2. Erland Sommarskog 93,131 Reputation points
    2023-10-31T22:47:05.6866667+00:00

    Open a query window. Noe the spid in the status bar. Start a restore of a database of some size (so that the restore complete directly).

    In a second window run, while the restore is running:

    SELECT * FROM sys.dm_tran_locks WHERE request_session_id = <spid in restore window>
    

    This will display the locks taken for the RESTORE.