• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 385
  • Last Modified:

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

Can I create a table or view  from a  UNION statement?
0
zachvaldez
Asked:
zachvaldez
  • 2
1 Solution
 
Patrick MatthewsCommented:
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
 
zachvaldezAuthor Commented:
Definitely work! Now I'll have the flexibility for creating datasource.
0
 
zachvaldezAuthor Commented:
Thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now