bcp - export and import data on SQL Server

15 December,2014 by Jack Vamvas

Question: How can I use bcp to export and import data on SQL Server ?

Answer:  Use the syntax in the examples below to Import and Export using bcp

To  export data from SQL Server  using bcp  

 

bcp "[MyDatabase].dbo.MyTable" out "MyTable.bcp" -N -S ServerName -T -E -U"xxxxxx" -P"xxxxxxx"

 

To import data from SQL Server using bcp :

 

bcp "[MyDatabase].dbo.MyTable" in "MyTable.bcp" -N -S ServerName -T -E -b 10000 -U"xxxxxx" -P"xxxxxxx"

 

These examples use the bcp native format    which is a binary format. It is possible that characters in the results may be unreadable.

The workaround for unreadable characters is to use a) character format i.e –c   if there is no Unicode data or b) if Unicode exists use -w

Read More on methods to move large amounts of data

SQL Server – Export Excel data to SQL Server with Powershell

How to output Query results to text file using bcp and queryout


Author: Jack Vamvas (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on bcp - export and import data on SQL Server


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer