Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need to copy rows between 2 databases same tables

Status
Not open for further replies.

HappyAdam

Programmer
May 6, 2010
6
US
I am trying to copy the rows from the tables in database spendanalyzer to database KPI to put then in customer id 1
in KPI from customerid 7 in Spendanalyzer - the following code is getting an error" Msg 102, Level 15, State 1, Line 4
Incorrect syntax near '1'."


SET IDENTITY_INSERT [KPI].[dbo].[Transactions] ON
GO


insert into KPI.dbo.Transactions
(customerid = 1, TransactionId, DepartmentId, ItemId, CategoryId, Quantity, Cost, DateCreated, InvoiceNumber, DataSource, DataSourceId, ImportId, LastUpdate)
select customerid = 7, TransactionId, DepartmentId, ItemId, CategoryId, Quantity, Cost, DateCreated, InvoiceNumber, DataSource, DataSourceId, ImportId, LastUpdate

from SpendAnalyzer.dbo.transactions
 
You have a typo in the Insert command. It should be

insert into KPI.dbo.Transactions
(customerid, TransactionId, DepartmentId, ItemId, CategoryId, Quantity, Cost, DateCreated, InvoiceNumber, DataSource, DataSourceId, ImportId, LastUpdate)
select customerid = 7, TransactionId, DepartmentId, ItemId, CategoryId, Quantity, Cost, DateCreated, InvoiceNumber, DataSource, DataSourceId, ImportId, LastUpdate

from SpendAnalyzer.dbo.transactions


PluralSight Learning Library
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top