Colsolidate 2 views SQL

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


grantballantyneAsked:
Who is Participating?
 
reb73Connect With a Mentor Commented:
SELECT * INTO dbo.TableC
FROM
(SELECT * FROM dbo.TableA
 UNION ALL
 SELECT * FROM dbo.TableB
) as Tmp
0
 
Forefront_Data_SolutionsConnect With a Mentor Commented:
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
All Courses

From novice to tech pro — start learning today.