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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:15:26+00:00 2026-05-16T08:15:26+00:00

I want to empty a temporary table, load it via bcp, and then modify

  • 0

I want to empty a temporary table, load it via bcp, and then modify its rows before moving to a production table. The commands would look something like this:

  1. truncate table temp1
  2. bcp db.schema1.temp1 in import1.txt -h “TABLOCK”
  3. exec sp_modify_temp1_rows_move_to_production_table

My question is how can I execute all this as one transaction, not necessarily in the interest of rolling it back, but in order to provide isolation.

Here is the imagined scenario. User1 goes to load import1.txt (the implementation details of how this done, steps 1-3, are hidden to the user). Before step 2 finishes for User1, User2 initiates their own import. Locking mechanisms prevent their import from starting right away. The primary concern is that User2 step 1 will begin as soon as User2’s step 2 is done thus clearing the table before User1’s step 3 and the process can be completed.

Three additional notes:

  1. Client side execution here via ADO (not to be mistaken with ADO.NET)
  2. BULK INSERT is NOT an option
  3. Prefer doing this via extending some lock mechanism via ADO that can include step 2 in with steps 1 and 2 of the process – if possible – knowing that it is impossible helps here also.
  • 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-16T08:15:27+00:00Added an answer on May 16, 2026 at 8:15 am

    The typical solution is to use applocks acquired via

    sp_getapplock 'importing-ABC', 'Exclusive', 'Session';
    

    This way you locks a logical resource (an arbitrary string/name) and, by convention, other users attempting to do the same must attempt to obtain the same applock. While the applock is held, the bcp command can run w/o interference. Note that this does not prevent another user/application that does not respect the protocol (because of ignorance, malevolence or stupidity).

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

Sidebar

Related Questions

If I want an empty map or a one element map, Java Collections has
I want to replace the text PATHTOEXPORT with the contents of a variable passed
I try to add a .mp3-file to an AVMutableCompositionTrack and after that I want
I am trying to create a video player in Adobe AIR. I want to
I have a jqgrid and after sending those grid records to server I want
With Jquery, is there some way to make val() return an empty string instead
Can I clone one textbox without its content??Means if I enter some values in
I have written a package for Mathematica called MathOO. In short, it allows you
We have a classic VBScript default.asp page in the root of our site. (This
I have a report in SSRS 2008 that has the following structure: List Tablix

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.