Ismail Lawal
Ismail Lawal

Reputation: 9

How to copy data from a table into another table

I have written a query as shown below to copy data from one table to the other. Everything seems ok but when the code is run, I get an error - Incorrect syntax near ','.

Please help.

USE [DWCNEW]

INSERT into DWCNEW..PostAP
SELECT TxDate, Id, AccountLink, TrCodeID, Debit, Credit, iCurrencyID, fExchangeRate, fForeignDebit, fForeignCredit, Description, TaxTypeID, Reference, Order_No, ExtOrderNum, cAuditNumber, Tax_Amount, fForeignTax, Project, Outstanding, fForeignOutstanding, cAllocs, InvNumKey, CRCCheck, DTStamp, UserName, iTaxPeriodID, cReference2, iAge, dDateAged, iPostSettlementTermsID, iTxBranchID, bPBTPaid, iGLTaxAccountID, bTxOnHold, PostAP_iBranchID, PostAP_dCreatedDate, PostAP_dModifiedDate, PostAP_iCreatedBranchID, PostAP_iModifiedBranchID, PostAP_iCreatedAgentID, PostAP_iModifiedAgentID, PostAP_iChangeSetID
FROM DWCLive22..PostAP

Upvotes: 0

Views: 62

Answers (1)

Arslan Ahmed
Arslan Ahmed

Reputation: 62

INSERT INTO newTable (col1, col2, col3)
SELECT column1, column2, column3
FROM oldTable

Upvotes: 1

Related Questions