Solved

How do you import/export data with BCP or Bulk Insert?

Posted on 2004-09-02
3
553 Views
Last Modified: 2008-02-26
How do you import/export data with BCP or Bulk Insert?

I have always used DTS but for a very large file it does not seem to be the best option
0
Comment
Question by:robrodp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
ram2098 earned 500 total points
ID: 11970521
BULK INSERT is basically used to trasnfer the data from a file to SQL Server. Remember this is a SQL Command and you can execute this using query analyzer (or) Stored Procedure directly.

Syntax as follows:

BULK INSERT Northwind.dbo.[Order Details]
   FROM 'f:\orders\lineitem.tbl'
   WITH
      (
         FIELDTERMINATOR = '|',
         ROWTERMINATOR = '|\n'
      )


BCP ..you can use to copy the data from a file to SQL Server (or) to a file from a SQL database. But, this you need to execute this from a command prompt. (or) using xp_cmdshell from query analyzer (or) Stored Procedures.

bcp "Northwind.Jane Doe.Jane's Orders" out "Jane's Orders.txt" -c -q -U"Jane Doe" -P"go dba"

You can see SQL Books online for more details about the arguments
0
 
LVL 11

Expert Comment

by:ram2098
ID: 11970530
And one more thing to add...

If you have files with specific delimiters to transfer to SQL (or) Vice Versa, using BCP (or) BULK INSERT is much simpler.

If you have files with fixed length, you need to use format files to do the transfer using BCP.
0
 
LVL 1

Expert Comment

by:Parag_Gujarathi
ID: 11970568
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question