Page History
Microsoft SQL Server uses locking to ensure the integrity of transactions and consistency in the database. Locking prevents data that users are reading from being changed by other users, and prevents multiple users from simultaneously changing the same data. If locking is not used, data within a database may become incorrect, and queries executed against that data may produce unexpected or invalid results. SQL Server automatically applies locks. However, you can make your applications more efficient by customizing or minimizing database locking.
The SQL Server Locks object provides information about locks that are applied to individual resource types. Locks are held on SQL Server resources such as rows read or rows that were modified during a transaction, and prevent the concurrent use of a resource by multiple transactions.
SQL Server can lock the following resources:
Resource | Description |
---|---|
Database | A database |
Extent | A contiguous group of eight data pages or index pages. |
Key | A row lock within an index. |
Page | An eight kilobyte data page or index page. |
RID | The identifier for a row in the database. |
Table | An entire table in the database, including all data and indexes. |
SQL Server locks resources using the following resource lock modes:
Shared (S) Locks
Allow concurrent transactions to read a resource. No other transactions can modify the data while shared (S) locks exist on the resource. Shared (S) locks are released when the data has been read, unless:
The transaction isolation level is set to repeatable read or higher.
A locking hint is used to retain the shared (S) locks for the duration of the transaction.
...
Used when bulk copying data into a table and either the TABLELOCK hint is specified, or the Table Lock on Build Load table option is set using sp_Tableoption. BU locks allow processes to bulk copy data concurrently into the same table while preventing other processes that are not bulk copying data from accessing the table.
Related Documentation
Configuring SQL Server Ports
Verifying the Configuration of SQL Server Ports