Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 create table

Author  Topic 

chriztoph
Posting Yak Master

184 Posts

Posted - 2009-06-10 : 22:14:33
hi to every one!

is it possible that you can create table using union?

sample:


CREATE TABLE sampleUNION
(SELECT * from sample2 UNION ALL
SELECT * from sample3 UNION ALL
SELECT * from sample4)


if not then what are the possible way to create?except create view..
thanks in advance?

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-06-10 : 23:00:27
Yes.

SELECT * INTO SAMPLEUNION
FROM(
SELECT * from sample2
UNION ALL
SELECT * from sample3
UNION ALL
SELECT * from sample4)Z
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-11 : 10:59:30
make sure number of columns in all tables are same as well as corresponding columns are of same data type.
Go to Top of Page
   

- Advertisement -