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

  • Home
  • SEARCH
  • 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 8467751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:44:05+00:00 2026-06-10T15:44:05+00:00

I have two tables a main table and a work in progress table. Any

  • 0

I have two tables a main table and a work in progress table. Any inserts/updates are inserted into the WIP table while the record is being manipulated, this allows for validation checks and the like. I want to create a view that combines the two tables showing the WIP table data whenever it exists and the main table data when there is no WIP data.

I have figured out a way to do this but it seems that it’s not the most elegant solution. I would like to know if there are other ideas or better solutions?

Example illustrating the situation:

select mt.id, wt.id wip_id, isnull(wt.name,mt.name) name, 
       isnull(wt.address, mt.address) address
from main_table mt full outer join
       wip_table wt on mt.id = wt.orig_id;

So that will pull results from the WIP table when they exist, if they dont it will pull results from the main table. This was a simple example but the tables could have many rows.

  • 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-06-10T15:44:07+00:00Added an answer on June 10, 2026 at 3:44 pm

    if you want data either from one table or the other:

    select top 1 *
    from
    (
    select 1 as prio, wt.name, wt.address, .... from wip_table wt where ...
    union
    select 2 as prio, mt.name, mt.address, .... from main_table mt where ...
    order by prio
    ) x
    

    otherwise, like you have done (checking individual columns), but maybe using a left outer join rather than a full one:

    select 
      mt.id
      , wt.id wip_id
      , isnull(wt.name,mt.name) name
      , isnull(wt.address, mt.address) address
    from main_table mt left outer join wip_table wt 
      on mt.id = wt.orig_id;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question regarding the design of two tables. Table 1: The main
I have two tables. Table1 is our main table of data and Table2 has
I have two tables. One is temp table and another is main table. In
Suppose I have two tables Main and Other like the following: Main +----------+-----------------------------------+ |
Good Afternoon All, I have two tables in my SQL Server 2005 DB, Main
I have two tables: table a ida valuea 1 a 2 b 3 c
I have two tables one with ID and NAME table 1 ID | NAME
I have two tables user table user_id | name | 1 | peter |
I have a form/subform for inputting data into an ado table. The main form's
I have two tables with hierarchyid fields, one of which is a staging table

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.