Warm tip: This article is reproduced from serverfault.com, please click

Bulk insert in SQL Server database from one table to another

发布于 2015-04-25 13:44:27

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

Questioner
666
Viewed
1
WaltRiceJr 2015-04-25 22:04:48

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.