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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:33:01+00:00 2026-05-29T11:33:01+00:00

I ran a query to copy 18 million records from one table to another.

  • 0

I ran a query to copy 18 million records from one table to another. Since the query was taking a long time to run I was monitoring the table count to tell when it would finish.

I noticed before it reached the number it should have reached the count started dropping back down so i checked the log and it looks like sql server basically ran out of memory:

‘The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time. Rerun your statement when there are fewer active users. Ask the database administrator to check the lock and memory configuration for this instance, or to check for long-running transactions.’

The actual insert only ran for about 20 minutes before the error showed up in the log.
I cancelled the query from management studio about 2 hours ago and judging by the table count this thing has only completed 25% which puts me at about 6 more hours. I’m assuming something along the lines of since all the memory is used up it is now running off the page file and that is why it is taking so long.

Is there anything I can do to speed this up? It has basically made the database unusable because everyone is getting the ‘cannot obtain a lock resource’ error. I could easily delete the inserted records myself, I’m wandering if perhaps I could kill the process id and ‘rollback’ the insert myself?

Update

This thing is till running remarkably slow. One thing I have found is that the # locks given by the following query seems outrageous: 83 million. The next highest is a whopping 20.

SELECT request_session_id, COUNT (*) num_locks
FROM sys.dm_tran_locks
GROUP BY request_session_id
ORDER BY count (*) DESC
  • 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-29T11:33:02+00:00Added an answer on May 29, 2026 at 11:33 am

    The solution that worked for me was to reboot the server. It did take 12 hours for the database I was working with to recover – but doing the reboot cleared up the resource issues we were having with applications accessing the other databases. The next time I tried this I broke it down into batches of 500K instead of all 18 million at once and everything worked fine.

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

Sidebar

Related Questions

I ran a query against Northwind database Products Table like below select * from
I recently ran into an issue where a query was causing a full table
This is a simple query ran when the user presses logout from my website
The same query ran in PL/SQL Developer shows time, however it does not show
I ran this query: SELECT i.name AS IndexName, s.used_page_count * 8 AS IndexSizeKB FROM
select * from tableName where somecode = '$$$$$$$&8Y~$$$$' when I ran this query in
There is a database it contains 2 million records approx in a table .
I just ran into a SQL query with about 5 different columns in the
I ran into an interesting error with the following LiNQ query using LiNQPad and
A co-worker recently ran into a situation where a query to look up security

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.