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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:05:38+00:00 2026-05-15T05:05:38+00:00

I heard about doing staging tables and I am wondering how you actually do

  • 0

I heard about doing staging tables and I am wondering how you actually do it.

I want to do a SqlBulkCopy into a staging table. Then then update the real table.

I heard in SQL Server 2008 that you can use something called merge but I am using SQL Server 2005 so I heard I have to use a update inner join?

I am not sure how that would look like(I am guessing best way would be to write it in SP). Also the staging table needs to be able to handle concurrent updates.

I was thinking of putting another column in the staged as GUID so that way I know which records belong to which group and when it is time to delete the records from the staged table I can just use that.

So can anyone show me any examples or tutorials on how to do it? Also how fast is this way? Say if your updating 50,000 records how long would that take(a guesstimate is fine)

Edit

So this is my SP now. I think it should be able to do concurrent connections but I wanted to make sure.

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sp_MassUpdate]
@BatchNumber uniqueidentifier 
AS
BEGIN
    update Product
    set ProductQty = 50
    from Product prod
    join StagingTbl stage on prod.ProductId = stage.ProductId
    where stage.BatchNumber = @BatchNumber

    DELETE FROM StagingTbl
    WHERE BatchNumber = @BatchNumber

END
  • 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-15T05:05:39+00:00Added an answer on May 15, 2026 at 5:05 am

    You create a staging table the same way you create a regular table. With a CREATE TABLE script that defines the columns and datatypes.

    OK

    update prod
    set field1 = stage.field1
    from myproductiontable prod
    join mystagingtable stage on prod.somefield = stage.somefield
    

    To add records not in prod

    Insert myproductiontable (f1, f2, f3)
    select stage.f1, stage.f2, stage.f3 
    from mystagingtable stage
    where  not exists (select someid from myproductiontable prod WHERE stage.somefield = prod.somefield)
    

    But you have to have one or more fields in the staging table that relate to the records in the prod table. Sometimes you have to do an additional join to get that relationship.

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

Sidebar

Related Questions

I want to know how to retrieve results in a SQL query doing some
I'm doing a small research on localisation methods in WPF. I heard about the
I am doing research about integrating a product into Dynamics Great Plains. I have
I heard about gems like faker or populator but they are a little bit
I heard about the chicken and the egg and bootstrapping. I have a few
I heard about the new entity framework for .net, and decided to modify my
I heard about B-Method which is invented in France. Is it an alternative to
I've heard about how base classes and method overriding can be combined to eliminate
I've recently heard about Qt and read about how fun it is to develop
I'v heard about aspects in a programming language and I was pretty enthusiastic about

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.