Questions tagged [bcp]

The bulk copy program `bcp` is a command line tool that can be used to export data from Microsoft® SQL Server™ or SAP Sybase Adaptive Server Enterprise databases to a data file in a user-specified format. bcp can also be used to bulk-load (=quickly import) data into the database server. The Microsoft and Sybase versions have similar syntax, but can not be used interchangeably.

The bcp utility copies data between an instance of Microsoft® SQL Server™ 2000 and a data file in a user-specified format

1159 questions
90
votes
5 answers

How to export data from SQL Server 2005 to MySQL

I've been banging my head against SQL Server 2005 trying to get a lot of data out. I've been given a database with nearly 300 tables in it and I need to turn this into a MySQL database. My first call was to use bcp but unfortunately it doesn't…
Mat
  • 6,694
  • 7
  • 35
  • 39
65
votes
13 answers

How to export SQL Server 2005 query to CSV

I want to export some SQL Server 2005 data to CSV format (comma-separated with quotes). I can think of a lot of complicated ways to do it, but I want to do it the right way. I've looked at bcp, but I can't figure out how to put the quotes around the…
John M Gant
  • 18,970
  • 18
  • 64
  • 82
47
votes
19 answers

Export table to file with column headers (column names) using the bcp utility and SQL Server 2008

I have seen a number of hacks to try to get the bcp utility to export column names along with the data. If all I am doing is dumping a table to a text file what is the most straightforward method to have bcp add the column headers? Here's the bcp…
JD Long
  • 59,675
  • 58
  • 202
  • 294
22
votes
13 answers

Unable to open BCP host data-file

Below is an example of the BCP Statement. I'm not accustomed to using BCP so your help and candor is greatly appreciated I am using it with a format file as well. If I execute from CMD prompt it works fine but from SQL I get the error. The BCP…
user2747607
  • 223
  • 1
  • 2
  • 4
21
votes
11 answers

bcp: Error = [Microsoft][SQL Server Native Client 10.0]String data, right truncation

I have recently encountered an error while working with bcp. Here is the error. SQLState = 22001, NativeError = 0 Error = [Microsoft][SQL Server Native Client 10.0]String data, right truncation I'm trying to unpack the data into a staging table…
cinnamon girl
  • 211
  • 1
  • 2
  • 3
19
votes
9 answers

Can I specify an input sql file with bcp?

How can I specify an input sql file with a long query when using bcp? I tried using the -i option but it keeps complaining about a command-line error with no extra information. Is this possible?
Legend
  • 113,822
  • 119
  • 272
  • 400
17
votes
2 answers

How to make Microsoft BCP export empty string instead of a NUL char?

I was working trying to get this bcp tool to work in a particular way. The -c switch is supposed to export using chars, but for some reason there was a weird char showing in Notepad++ like if it was UNICODE or some other formatting. I wanted to get…
mimoralea
  • 9,590
  • 7
  • 58
  • 59
16
votes
4 answers

Bulk Load Files into SQL Azure?

I have an ASP.NET app that takes multimegabyte file uploads, writes them to disk, and later MSSQL 2008 loads them with BCP. I would like to move the whole thing to Azure, but since there are no "files" for BCP, can anyone comment on how to get bulk…
Snowy
  • 5,942
  • 19
  • 65
  • 119
15
votes
10 answers

Unexpected EOF encountered in BCP

Trying to import data into Azure. Created a text file in Management Studio 2005. I have tried both a comma and tab delimited text file. BCP IN -c -t, -r\n -U -S -P I get the error {SQL Server Native Client 11.0]Unexpected EOF encountered in…
alemus
  • 314
  • 1
  • 2
  • 17
13
votes
4 answers

Installing BCP without installing SQL Server in client machine?

I export data from database using the BCP utility, I want to install bcp in client machine. I don't want to install SQL Server 2008 in client machine. Is their any minimal installers available to install just bcp? This is urgent task. Thanks in…
Ramakrishnan
  • 5,254
  • 9
  • 34
  • 41
12
votes
4 answers

BCP Utility Unable to Export Data in Linux Using JAVA:

I tried to execute the following piece of code to export data(myFileName.csv) : bcp "select * from DataBase.schema.TABLE_NAME" queryout tableData.csv -c -t, , -S [server] -U [user] -P '[password(with special characters)]' > LogFile.txt the above…
12
votes
2 answers

How do I use BCP or Sql Server Management Studio to get BLOB data out of Sql Server?

I'm sorry if this question has been asked already, but I couldn't find it anywhere. I have a table that stores files as BLOBS. The column that holds the file is an image datatype. I would like to be able to extract the binary data out of the…
Eric
  • 3,284
  • 1
  • 28
  • 29
12
votes
3 answers

Why do I get "XML parsing: line 2, character 0, incorrect document syntax" when Bulk Inserting in MS SQL Server

I'm doing a BULK INSERT into a table using a FMT format file, but I get the following error: XML parsing: line 2, character 0, incorrect document syntax Here is my code BULK INSERT [DM_Flux].[dbo].[Stage] FROM 'C:\temp\data.dat' WITH (FORMATFILE =…
Cros
  • 4,367
  • 9
  • 41
  • 47
11
votes
4 answers

BCP error "Unable to open BCP host data-file"

I've just create a new table in my sqlserver name exporttable now I'm trying to push out using cmd bcp but om getting this following error: SQLState = S1000, NativeError = 0 Error = [Microsoft][ODBC Driver 13 for SQL Server]Unable to open BCP…
MK55SDV
  • 137
  • 1
  • 2
  • 7
11
votes
1 answer

Error = [Microsoft][ODBC Driver 11 for SQL Server]Warning: BCP import with a format file will convert empty strings in delimited columns to NULL

I upgraded our Windows Server from 2008 to 2012 and the SQL Server from 2008 to 2014. I have a process that uses the BCP command to export data from the database. The command is below: bcp "exec db_name.dbo.table_name 20160204, 0" queryout…
nobody
  • 10,892
  • 8
  • 45
  • 63
1
2 3
77 78