Solved

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

Posted on 2004-09-02
3
531 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
  • 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now