Skip to content
Advertisement

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:orderslineitem.tbl'
 WITH 
  (
     FIELDTERMINATOR =' |',
     ROWTERMINATOR =' |n'
  );

What is f:orderslineitem.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

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement