Solved

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

Posted on 2011-09-09
3
369 Views
Last Modified: 2012-05-12
Can I create a table or view  from a  UNION statement?
0
Comment
Question by:zachvaldez
[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
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
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…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

734 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