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
11
votes
3 answers

What will be BCP format for inserting a identity column

I am facing problem while I am trying to insert data to a table using BCP. The table has a identity column. I am taking input from a text file. Please let me know if there are any good solutions. Regards, Chayan
Chayan
  • 11
  • 1
  • 1
  • 4
11
votes
7 answers

SQL Server BCP: How to put quotes around all fields?

I have this BCP command: 'bcp DBName..vieter out c:\test003.txt -c -T /t"\",\"" -S SERVER' The output CSV I get does not put quotes around the field names, instead it puts it around the commas! How can I get the /t"\",\"" to put quotes around all…
Abs
  • 56,052
  • 101
  • 275
  • 409
11
votes
5 answers

Getting bcp.exe to escape terminators

I need to export some data using SQL Server 2000's BCP utility. Sometimes my data contains characters, such as \t and \n, that I need to use as column and row terminators. How do I get BCP to escape characters it's using as terminators as it…
Kev
  • 15,899
  • 15
  • 79
  • 112
10
votes
5 answers

What is the best way to save XML data to SQL Server?

Is there a direct route that is pretty straight forward? (i.e. can SQL Server read XML) Or, is it best to parse the XML and just transfer it in the usual way via ADO.Net either as individual rows or perhaps a batch update? I realize there may be…
alchemical
  • 13,559
  • 23
  • 83
  • 110
10
votes
1 answer

Rollback for bulk copy

I have an application that make a copy from my database by bulk copy class in c#. Can I rollback the bulk copy action in sql server when occur an exception?
masoud ramezani
  • 22,228
  • 29
  • 98
  • 151
10
votes
3 answers

Why does bcp output null when the column contains an empty string and empty string when the column is null?

This struck me as really weird behaviour and I spent a while checking for bugs in my code before I found this "out copies from the database table or view to a file. If you specify an existing file, the file is overwritten. When extracting data, note…
David Hayes
  • 7,402
  • 14
  • 50
  • 62
10
votes
2 answers

BCP returns no errors, but also doesn't copy any rows

I'm trying to dump a very large set of data from a .csv file into a SQL Server 2012 database. Rather than doing thousands of INSERTs, I'm investigating bcp. EDIT: This is for an automated process, and not just a one-off. I also do not have BULK…
Mark
  • 3,609
  • 1
  • 22
  • 33
9
votes
6 answers

How to remove NULL char (0x00) from object within PowerShell

I have a .CSV file that I created using SQL Server's BCP command-line BULK-COPY utility to dump a bunch of database tables. Since I want to import these .CSV file's using Powershell and convert them to a nice report using the format-table cmdlet,…
user500741
  • 833
  • 5
  • 14
  • 25
9
votes
3 answers

Sql Bulk insert XML format file with double quotes in terminator

I'm trying to insert some data into a table from a csv document which has all of the fields delimited with "" ie. APPLICANTID,NAME,CONTACT,PHONENO,MOBILENO,FAXNO,EMAIL,ADDR1,ADDR2,ADDR3,STATE,POSTCODE "3","Snoop Dogg","Snoop…
Daniel Powell
  • 8,143
  • 11
  • 61
  • 108
9
votes
2 answers

Best way to export/import MS Sql 2008 Geography data

(ANSWER) How to export some Geography data from a Microsoft Sql Server 2008. You'll need to use the command line argument BCP to dump the data in it's original (native) format to a binary file. Then on the other server you can bulk insert this…
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
9
votes
4 answers

Can Sql Server BULK INSERT read from a named pipe/fifo?

Is it possible for BULK INSERT/bcp to read from a named pipe, fifo-style? That is, rather than reading from a real text file, can BULK INSERT/bcp be made to read from a named pipe which is on the write end of another process? For example: create…
Peter Radocchia
  • 10,710
  • 2
  • 34
  • 56
9
votes
1 answer

Using bcp utility to export SQL queries to a text file

I debug a stored procedure (SQL Server 2005) and I need to find out some values in a datatable. The procedure is run by an event of the application and I watch just the debugging output. I do the following my stored procedure (SQL Server 2005), I…
serhio
  • 28,010
  • 62
  • 221
  • 374
8
votes
4 answers

Use bcp to import csv file to sql 2005 or 2008

I have a csv file and i need to import it to a table in sql 2005 or 2008. The column names and count in the csv are different from the table column names and count. The csv is splitted by a ';' . Example CSV…
MichaelD
  • 8,377
  • 10
  • 42
  • 47
8
votes
3 answers

What are the binary storage formats for sqflt8, sqlmoney and other native SQL data types?

According to the documentation, native (binary) data can be imported or exported with bcp formatted in the native SQL Server data formats. Examples of these are SQLFLT8, SQLFLT4, SQLMONEY or SQLNUMERIC. Does anyone know either what the data formats…
ConcernedOfTunbridgeWells
  • 64,444
  • 15
  • 143
  • 197
8
votes
4 answers

Exporting SQL Server Table to multiple part files

I need to export a fairly large SQL Server table ~100GB to a CSV file. But rather than the output be a single csv file, it should ideally be multiple files say 10 files each 10GB. I see BCP has a batch_size argument but this still writes all data to…
Jon
  • 678
  • 1
  • 6
  • 9
1
2
3
77 78