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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:10:05+00:00 2026-05-16T04:10:05+00:00

I am populating a table that acts as a cache. (This is needed because

  • 0

I am populating a table that acts as a cache. (This is needed because the data comes through a linked server and joins through the link are too expensive)

I’ve included pseudo code below that hopefully demonstrates what I’m trying to do. I really don’t know if there’s a way to lock a table down like this, or if I need to use transactions, but here’s the basics:

  1. Delete everything in the CacheTable
  2. Populate the cacheTable
  3. Process the data in CacheTable for 10 seconds (it’s important that other instances of this stored procedure don’t delete the CacheTable during processing!)
  4. Return the processed results (CacheTable is free again)

 delete from CacheTable -- If this errors because it is locked, exit stored procedure

 [[Lock CacheTable]] 
 insert into CacheTable
 exec RemoteDB.dbo.[sp_GrabRecords] @Start, @End, @Key

 Process Cached Data
 ...
 Select Processed Data

 [[Unlock CacheTable]]

How can I protect the data in this CacheTable while it is being processed?

Note: I’m also looking for alternatives. I tried using a table variable, but it was too slow, probably because it didn’t have a primary key. Not even sure if tables variables can have primary keys. I just know the method above is extremely fast, but it has a problem with collisions, obviously

  • 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-16T04:10:05+00:00Added an answer on May 16, 2026 at 4:10 am

    isn’t that CacheTable a temporary table, so each instance of the stored procedure should allocated it’s own; thus avoiding the locking problem

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

Sidebar

Related Questions

The reason why I am having a hard time populating this table is because
I have a feed that is populating a single text field in a table
im populating the data in the combo box using dataset tables...with some table name..now
I realized after populating the table that it contains special encoding for foreign characters.
I am having an issue populating a data table with the correct data. I
I have a html table that I am populating with PHP, now it is
I have a procedure that runs every one hour populating a table. The records
Back again I'm afraid! I have this SQL Query - populating a table. echo
I am populating a secondary table with an observable array that is a child
I am populating a table with a vector however there are some empty cells

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.