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 6870409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:40:49+00:00 2026-05-27T03:40:49+00:00

There is a process that runs ever hour that has to insert into table1

  • 0

There is a process that runs ever hour that has to insert into table1 but when the query below is running, the inserts are blocked. Can anyone explain why? I realize that the lock hints are just that, hints and SQL may chose to ignore them. table1 has 300m rows and I need to update the values in ColumnA. I’m doing it in chunks to help with the rollback in case the process has to be stopped, hence the while loop.

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
go

declare @start bigint
declare @end bigint
declare @max bigint
declare @step int

set @step = 50000
set @start = 17953095
set @end = @start + @step
set @max = @start + 2000000

while ( @end < @max )
begin

waitfor delay '00:00:10'

begin transaction

update [table1] with (ROWLOCK)
set [table1].[ColumnA] = [table2].[ColumnA]
from [table2] (nolock)
where [table2].[ColumnB] = [table1].[ColumnB] 
and [table1].ID >= @start 
and [table1].ID <  @end

commit transaction

print @end

if @end >= @max 
begin
    break
end

set @start = @end
set @end = @end + @step

end

print @end

Can I do this another way so it doesn’t block the inserts or other updates? Nothing else will need to work with ColumnA other than my query above.

  • 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-27T03:40:50+00:00Added an answer on May 27, 2026 at 3:40 am

    You can try using a smaller batch size. SQL Server escalates row locks straight to table locks when a certain threshold is exceeded, per MSDN:

    The Database Engine does not escalate row or key-range locks to page
    locks, but escalates them directly to table locks.

    …
    …
    Lock escalation is triggered when lock escalation is not disabled on
    the table by using the ALTER TABLE SET LOCK_ESCALATION option, and
    when either of the following conditions exists:

    A single Transact-SQL statement acquires at least 5,000 locks on a
    single nonpartitioned table or index.

    A single Transact-SQL statement acquires at least 5,000 locks on a
    single partition of a partitioned table and the ALTER TABLE SET
    LOCK_ESCALATION option is set to AUTO.

    The number of locks in an instance of the Database Engine exceeds
    memory or configuration thresholds.

    If locks cannot be escalated because of lock conflicts, the Database
    Engine periodically triggers lock escalation at every 1,250 new locks
    acquired.

    Your current batch size of 50,000 is well in excess of that threshold.

    The other thing to think about is whether you have suitable indices in place to suit your WHERE clause – make sure that is as optimal as possible.

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

Sidebar

Related Questions

There is any command line or .NET method that runs a process in the
Is there a way in the .NET framework to validate that a process has
Hi I've got an app that runs a long running process on the command
The application has a CPU intensive long process that currently runs on one server
In my web application there is a process that queries data from all over
In a system I am currently working on, there is one process that loads
There is a conversion process that is needed when migrating Visual Studio 2005 web
Is there a way to get the PID from a process that is blocking
In this particular situation, there are 9 automated steps in a process that take
There is a feature in Sysinternal's Process Explorer that allows a crosshair to be

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.