bcp

How to write an error message from an BCP operation to a log file and stop processing the batch file.

I have a BCP operation in a batch command file. when there is an error in the BCP Operation I need to stop the processing and write the err msg in the log file I've used to -e option to write the error message during a BCP operation to a err file. The err file is getting created in the location but does not contain any error message wr...

Bulk Copy from one server to another

I've one situation where I need to copy part of the data from one server to another. The table schema are exactly same. I need to move partial data from the source, which may or may not be available in the destination table. The solution I'm thinking is, use bcp to export data to a text(or .dat) file and then take that file to the destin...

Master/Detail insert using BCP?

I've a master table with identity on for the primary key and I've some child tables. When I insert a record to the master table using BCP, how can I use the newly created ID from the master table to insert in the related child tables (May be BCP again)? Will it be possible? I may be able to set identity off, but, will it work? Thanks J...

Bulkinsert from CSV into db (C#) -> max number of rows in a web application?

Web application - C#, .Net, SQL 2k5. I recently used bulkinsert on an other application and I thought I would like to give it a try. I am going to receive a CSV file with 1000 rows, which will most likely add 500 000 (that is five hundred thousand) records in the database. I don't have any idea yet about this huge amount if it's going t...

What is the quickest way to import 60m records into SQL

I have a 5-6 tables in my database that I need to populate with test data to test peroformance in my app. I can write a code and do a bulk insert my prediction is that it will take nearly 3 days to run so I assumed there must be a quicker way. Any ideas? ...

BCP task hangs while executing

Hey guys, We have a HPC node that runs some of our tasks in it. I have a task in my .net project that kicks the bcp utility on the HPC node and the output of the query that I have runs into 9 Mb. When the HPC node runs this task the output of the query is dumped into a file and then after it dumps around 5mb of data it suddenly stops ...

Are there wildcards for BCP?

I'm trying to run a command script that executes a BCP utility. I want it to be able to find any files with a specific file name format, for example, fileyyyymmdd.dat. Is there any way of replacing the yyyymmdd with wildcards, like a ? or * in other programs? Thanks! ...

What will be BCP format for inserting a identity column

Hi, 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 ...

SQL Server 2008 and the commandline tool bcp: are there different versions around?

I got the problem having written a little procedure to import some flatfiles in a table using openrowset...bcp... which didn't work at customers site. A short check with bcp /? shows a different behaviour e.g. the switch -T was not trusted connection but rather something with Images. Are there different versions of bcp delivered? ...

Moving from 32-bit to 64-bit, how to make linked server (sp_addlinkedserver) work

Here is some sample code that worked fine in a 32-bit machine (SQL server 2005) and needs to be updated for a 64-bit... I know this is a common problem but have not been able to find how to fix it! DECLARE @sourceFile varchar(255), @testRows int SELECT @sourceFile = @xmlInfo.value('(/SelectFile/DataSource)[1]', 'VARCHAR(100)') ...

How to specify row separators when importing into an sqlite db from a csv with non-default field and row separators ?

I have a bunch of data that i exported from mssql using bcp with custom field and row separators. I would like to import the data into an sqlite database. . Is there an easy way to do this with .import and .separator ? . Or do I need to use a newline as my row separator, alter the .import source, or make insert statments for each row...

BCP utility to create a format file, to import Excel data to SQL Server 2008 for BULK insertion

Am trying to import Excel 2003 data into SQL table for SQL Server 2008. Tried to add a linked server but have met with little success. Now am trying to check if there's a way to use the BCP utility to do a BULK insert or BULK operation with OPENROWSET, using a format file to get the Excel mapping. First of all, how can I create a form...

Why did Boost's `bcp smart_ptr dir/` copy 6MB of source code?

So I wanted to separate out just the smart pointers from boost to use in my project and I was guided to use bcp utility. Today I got it compiled and did bcp smart_ptr to_copy_to_my_project/. The result: 6MB of code in to_copy_to_my_project/ directory. Are you kidding me? I don't want to add 6MB of header files to my 100KB project just...

Help me use powershell and bcp to load CSV into SQL Server

I'm using bcp to load a table from a CSV exported from another table by someone else far far away, and have run into some issues. My original two problems: one exported field is an int that needs to end up in a varchar field, and another field needs to be populated with a static string. Well, the first is no big deal, and Chad's answer l...

Way to create a table from a flat file in SQL Server without knowing datatypes?

Is there a way to load a flat file into SQL Server as a new table without knowing the data types of the columns in the file? I know one can use BULK INSERT to load flat file data, but a target table must first be created that matches the datatypes in the incoming file. OPENROWSET requires the creation of a format file that specifies th...

bcp queryout "for xml path" delimiters

Hello, I am trying to export to xml file using bcp command with queryout and select... FOR XML PATH option. I have a test data of 5000 records. Expected output is: <row> <column1><\column1> <column2><\column2> <\row> *line break here* <row> <column1><\column1> <column2><\column2> <\row> *line break here* However, bcp doe...

SQL Server BCP only one row inserted?

I'm using an FMT file to BCP a csv file into a an SQL Server Box - everything is fine, but only the first row of the 5 line file is getting inserted. I think it is the line feed settings for the terminator of the final column - but how do I view and edit the line feeds in the csv file? ...

Correct BCP syntax

I am a first time BCP user. I have an XML file that I need to import into a new table in SQL Server. This is using SQL Server 2008 and BCP version 10.50.16. I read through the documentation but I get 370,000 errors! (This is a very large file). When I open the error log, I just see a bunch of question marks. About this XML file: i...

SQLState=S1000, NativeError=0

I am trying to use the BCP command to execute the following statement, but I keep getting the following error: Starting copy... SQLState = S1000, NativeError = 0 Error = [Microsoft][SQL Server Native Client 10.0]Unexpected EOF encountered in BCP data-file 0 rows copied. Network packet size (bytes): 4096 Clock Time (ms.) Total : 1 ...

Getting a buildable Boost extract with bcp

I'm using bcp to extract Boost.Archive from Boost. Unfortunately I can't build this extract. Boost.Archive is not a header-only library. bjam complains Unable to load Boost.Build: could not find "boost-build.jam" Is there any way to tell bcp to make the extract buildable with bjam (copy boost-build.jam to the right place)? ...