Fundamentals of Exporting and Importing Data

One of the great things about bcp is its ease of use. This section runs through a couple simple examples and provides full explanations. All tables used here can be found in the AdventureWorks2008 sample database supplied by Microsoft in SQL Server 2008.

Let’s start by exporting product data from AdventureWorks2008 that may be needed by a sales team for reference in Excel format (a .csv file). To do this, you simply export the Product table data into a comma-delimited file. You need to specify the following with bcp in this case:

• The full table name (in this case, AdventureWorks2008.Production.Product)

• The direction of bcp (OUT in this case because it is exporting data out)

• Data filename to ...

Get Microsoft® SQL Server 2008 R2 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.