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.
| Author |
Topic |
|
vamsimahi
Starting Member
29 Posts |
Posted - 2008-04-11 : 12:32:23
|
| Hi,I am new to SQL and i am trying to create a table from a table. below is my query but im getting an errorCREATE TABLE Production.TransactionHistoryArchive1 AS(SELECT ProductID,SUM(Quantity) QuantitySum,SUM(LineItemTotalCost) TotalCostByID FROM Production.TransactionHistoryArchiveGROUP BY ProductID)error:Msg 156, Level 15, State 1, Line 1Incorrect syntax near the keyword 'AS'. |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2008-04-11 : 12:34:44
|
| read in BOL about SELECT INTONathan Skerl |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-04-11 : 12:35:26
|
| 1)Create table with same structure2) Insert into Production.TransactionHistoryArchive1 SELECT ProductID,SUM(Quantity) QuantitySum,SUM (LineItemTotalCost) TotalCostByID FROM Production.TransactionHistoryArchiveGROUP BY ProductIDOr use Export/Import Wizard. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-11 : 12:37:41
|
| You cant create a table like this. AS nathans pointed out use SELECT INTO |
 |
|
|
vamsimahi
Starting Member
29 Posts |
Posted - 2008-04-11 : 12:42:06
|
| thank you nathan it worked... |
 |
|
|
|
|
|