Which locks are acquired during database restore

Chaitanya Kiran 796 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.
13,785 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 64,901 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 111.1K Reputation points MVP
    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.