Solved

Can I create a table or view  from a  UNION statement?

Posted on 2011-09-09
3
326 Views
Last Modified: 2012-05-12
Can I create a table or view  from a  UNION statement?
0
Comment
Question by:zachvaldez
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 250 total points
ID: 36513301
Yes.

CREATE VIEW dbo.MyView AS
SELECT a, b, c
FROM Table1
UNION
SELECT a, b, c
FROM Table2

Open in new window


Creating a table...

SELECT z.a, z.b, z.c
INTO NewTable
FROM
    (SELECT a, b, c
    FROM Table1
    UNION
    SELECT a, b, c
    FROM Table2) AS z

Open in new window

0
 

Author Comment

by:zachvaldez
ID: 36514102
Definitely work! Now I'll have the flexibility for creating datasource.
0
 

Author Closing Comment

by:zachvaldez
ID: 36514111
Thanks!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now