Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5842631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:02:34+00:00 2026-05-22T12:02:34+00:00

I know a key lock locks a key in an index. However, what does

  • 0

I know a key lock locks a key in an index. However, what does “key” actually mean?

For example, if I have a non-clustered index on a surname column and attempt an update where surname = “Jones”, will I have effectively locked every row in the table where the surname is “Jones”? Or will the index be locked at a higher level, preventing access of rows with surnames other than “Jones”?

The reason I ask is this note in Books Online about Lock Granularity and Hierarchies:

KEY: A row lock within an index used to protect key ranges in serializable transactions.

This suggests a range of keys will be locked, not just one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:02:35+00:00Added an answer on May 22, 2026 at 12:02 pm

    A keylock affects all rows that match the given predicate (kind of) – in your example all rows with surname = 'Jones' will be affected.

    The word “range” is used because depending on the predicate a range of rows may be affected, for example if the predicate was age > 18 then all rows where the age is greater than 18 would be affected.


    It is also important to understand that a key lock does not simply individually lock each matching row in the index – your example keylock not only affects all existing rows in the index with surname “Jones”, it also affects any attempt to modify an existing row or insert a new row with surname “Jones”.

    It may help to think about locks in a slightly different way – locks only have an effect when SQL Server attempts to obtain another lock which may be incompatible (i.e. it is not legal to have both locks at the same time). For example if you have an exclusive key-lock on rows with age > 18 and attempt to insert or modify a row with age = 42 then SQL server will first attempt to obtain the relevant locks – seeing that there is an existing key lock for rows with age > 18 SQL Server determines that the locks are incompatible and takes action accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know PRIMARY key is to have unique value, what about INDEX? What is
I know the ESC key does code completion, but is there a way to
We use GUIDs for primary key, which you know is clustered by default. When
Does anybody know a way to set/get the fn-lock from an application so you
sorry i have many questions about the lock/cache.=_=.. ->1. about cache, i know that
Does anyone know the key issues that the Rails 3.1 IdentityMap feature has that
OK, so I know I can remap the Caps Lock key in Windows registry,
I have to activate android's system key lock (the one you get when you
I know what a key is, I know what opaque is in other contexts
I know there is a registry key indicating the install directory, but I don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.