364,111 Members | 2013 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

Create table as copy of existing table

Shrutisinha
P: 25
Hi Guys
Really need your help I donno what I am doing wrong in here
Want to create a table with another existing table
Here is the syntax I am using

create table pctemp1
As
(SELECT distinct a.Promo,b.Ban,b.[Ban Status],
b.[BAn Statys Reson Code],b.[Last Ban Status Date]
FROM PC_FUSION_070424 a
LEFT OUTER JOIN ARCL05_070423 b
ON a.BAN = b.BAN
WHERE b.BAN is not null )

and it says Syntax error with AS clause, tried removing AS clause but no go , can anybody help me please ...

thanks
May 2 '07 #1
Share this Question
Share on Google+
4 Replies


iburyak
Expert 100+
P: 1,017
Try this:

[PHP]

SELECT distinct a.Promo,b.Ban,b.[Ban Status],
b.[BAn Statys Reson Code],b.[Last Ban Status Date] into pctemp1
FROM PC_FUSION_070424 a
LEFT OUTER JOIN ARCL05_070423 b
ON a.BAN = b.BAN
WHERE b.BAN is not null [/PHP]

Good Luck.
May 2 '07 #2

jojo41300000
P: 32
Hi Guys
Really need your help I donno what I am doing wrong in here
Want to create a table with another existing table
Here is the syntax I am using

create table pctemp1
As
(SELECT distinct a.Promo,b.Ban,b.[Ban Status],
b.[BAn Statys Reson Code],b.[Last Ban Status Date]
FROM PC_FUSION_070424 a
LEFT OUTER JOIN ARCL05_070423 b
ON a.BAN = b.BAN
WHERE b.BAN is not null )

and it says Syntax error with AS clause, tried removing AS clause but no go , can anybody help me please ...

thanks
Add column name for new table will solve the problem.

create table pctemp1(column,..., column)
As
(SELECT distinct a.Promo,b.Ban,b.[Ban Status],
b.[BAn Statys Reson Code],b.[Last Ban Status Date]
FROM PC_FUSION_070424 a
LEFT OUTER JOIN ARCL05_070423 b
ON a.BAN = b.BAN
WHERE b.BAN is not null )
May 3 '07 #3

vamsi27
P: 1
select * into Newtable_A from Existingtable_B

This will work out for you
Oct 7 '07 #4

MuthuFrank
P: 1
HI BUDDY..

i think that(wat u have given) command will work in oracle..in sql

select * into newtable from existing table where 1=0;

this will create a structure based on existing table..
better u check this command
Jan 23 '08 #5

Post your reply

Help answer this question



Didn't find the answer to your Microsoft SQL Server question?

You can also browse similar questions: Microsoft SQL Server