Monday, August 31, 2009

MCTS 70-433 SELECT .. INTO

Another "gotcha" when working with Oracle and SQL Server, is that in Oracle you have the "CREATE TABLE AS" statement where as in SQL Server you use the "SELECT .. INTO " statement


http://bytes.com/topic/sql-server/answers/640806-create-table-copy-existing-table


Question


May 2nd, 2007, 12:57 PM

Shrutisinha (Newbie) 

Join Date: Feb 2007  Posts: 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


Answer:


May 2nd, 2007, 03:51 PM

iburyak (Expert) 

Join Date: Nov 2006  Posts: 1,017

re: Create table as copy of existing table

Try this:


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 


Good Luck.

No comments: