Solved

Colsolidate 2 views SQL

Posted on 2011-03-01
2
236 Views
Last Modified: 2012-06-22
Dear Experts

I have two views with exactly the same amount of columns and column names.

Each of the views hold different data and I would like to create another view to consolidate the data.  Is this possible.

For Example

Table A                      Table B
pRef                           pRef
pAddress1                pAddress1
pAddress2                pAddress2
pTown                       pTown


Am I able to consolidate this data into (Table C)

Thanks


0
Comment
Question by:grantballantyne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 25

Accepted Solution

by:
reb73 earned 250 total points
ID: 35007014
SELECT * INTO dbo.TableC
FROM
(SELECT * FROM dbo.TableA
 UNION ALL
 SELECT * FROM dbo.TableB
) as Tmp
0
 
LVL 8

Assisted Solution

by:Forefront_Data_Solutions
Forefront_Data_Solutions earned 250 total points
ID: 35007021
The simplest way would be to use the UNION operator.  Copy the SQL from View A add the UNION operator, then copy the SQL from View B.  Like this:

Select somestuff
from ATable

UNION

Select someotherstuff
from BTable


The most efficient way would be to analyze the data from the original two tables and write a query that retrieves the desired data.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question