Solved

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

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

829 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