Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2013

    Unanswered: Lock on table while inserting data in SQL Server database

    I have question on lock on table in SQL Server while inserting data using multiple processes at a single time into same table.

    Here are my questions on this,
    1) Is it default behavior of SQL server to lock table while doing insert?
    2) if yes to Q1, then how we can implicitly mention while inserting data.
    3) If I have 4 tables and one table is having foreign keys from rest of the 3 tables, on this scenario do I need to use the table lock explicitly or without that I can insert records into those tables?

    Please help me to understand the same.

    Last edited by Sat08536; 07-10-14 at 11:33.

  2. #2
    Join Date
    Nov 2004
    on the wrong server
    Provided Answers: 6
    1) Not the whole table, no. Locks start at the lowest level of granularity and escalate as needed.
    2) I am not sure what you mean here.
    3) You never have to use hints to INSERT data.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts