user786
user786

Reputation: 4364

Bulk insert in SQL Server database from one table to another

I have 200k records in one table and I want to insert these records into another table. I read about the bulk insert but the query I found on msdn website is just not making any sense.

This is the query

 BULK INSERT AdventureWorks2012.Sales.SalesOrderDetail
 FROM 'f:\orders\lineitem.tbl'
 WITH 
  (
     FIELDTERMINATOR =' |',
     ROWTERMINATOR =' |\n'
  );

What is f:\orders\lineitem.tbl and the whole this is just not making any sense.

I have a table with four columns: id, frm, to1 and country

Same this in destination table

Any easy syntax will be helpful

I am using SQL Server 2008/12

Upvotes: 7

Views: 42793

Answers (3)

Abbas Hadavandi
Abbas Hadavandi

Reputation: 169

insert into destinationsever.destinationdatabase.dbo.destinationtable
select * from sourcesever.sourcedatabase.dbo.sourcetable

Upvotes: -1

Asghar nafe merkid
Asghar nafe merkid

Reputation: 1

Bulk insert is for import external data from file to sql table like

BULK INSERT 'tableName' From 'File Path',

If You have Copy data from one table to other table in sql, use:

select into instate insert into like ' select * into table1 From table2

Upvotes: 0

WaltRiceJr
WaltRiceJr

Reputation: 151

BULK INSERT imports from an external data file. If you already have the data in a SQL Server table, then you should do something like:

INSERT INTO NewTable (field1, field2, field3)
SELECT field1, field2, field3 FROM OldTable

DO NOT point BULK INSERT at your SQL Server database file. The .tbl file referenced in your example code is to a text file with delimited fields.

Upvotes: 11

Related Questions