bcp

Does bcp out maintain row order while exporting into a data file?

I need to export data to a file from a huge table with only one column but thousands of rows where the ordering of row is important. I am using bcp command as below bcp DBNAME.dbo.tblName out mydata.dat -Uusername -Ppassword -c I checked with the table having 10 rows and I see that the order of the rows is maintained in the data file...

question about bcp utility in sql server

If I have data rows in database and want to import data from data file with bcp utility in native mode, is there any solution (specified switch) that override data with same identity value in ID column? ...

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

Hello all, 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 fields. Thanks all ...

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 for the various types are, or where documentation specifying these formats might be foun...

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 = 'C:\temp\FormatBcp.fmt') Here is the formatfile (standard format file, not XML): 10...

SQL SERVER 2005 BCP Format File Creation Error

I am having an issue with SQL Server 2005's BCP utility. I am running SQL Server Express 2005 on Windows Vista. I am trying to create a non-XML format file for some tables in my database. I run the following code: bcp 'jProd_000-1'.users format nul -T -f users.fmt I get the following error: An Error occurred while processing the...

boost::asio extraction with bcp and no threads

I want to use boost::asio in a project by itself. I am not using threads, but when I use bcp to extract asio it pulls out ALOT of code including the thread stuff. How can I use bcp to only pull out what I need for simple single threaded socket routines? ...

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 named pipe unzip file to named pipe read from named pipe with bcp or BULK INSERT or: ...

BCP Command gives different output in SQL Server 2005 compared to 2008?

Hello all, I have executed two identical bcp commands on two different setups with the same data. Machine A = Windows Vista machine which is running SQL Server 2008 Machine B = Windows Server 2003 machine running SQL Server 2005 The output text file of the bcp command is different! For a start, Machine B does not add column names to ...

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? ...

Create a file in Java for loading into an nvarchar field in SQLServer 2005 using BCP and UTF-16

Hi All, I want to use BCP to load into a SQL Server 2005 table with an nvarchar field using a loader control file. As I understand it, SQL Server 2005 only supports UTF-16 (and I believe it is UTF-16 LE). The file is being output by a Java program. The way I have it currently set up is as follows: An XML format BCP loader file (cre...

Bulk insert XML data into SQL Server

Using the table structure below how would I create a bcp bulk insert that would handle the XML data. It is important that this is run from command line. CREATE TABLE [dbo].[MyTable]( [Id] [uniqueidentifier] NOT NULL DEFAULT (newid()), [MyXmlField] [xml] NULL Thanks in advance... ...

BCP database with period in name

I'm having trouble using the SQL BCP process to load up my tables with data. I'm calling it from a .NET application, so I execute the xp_cmdshell executable to run the bcp command. Here is what one of these commands looks like: EXEC master..xp_cmdshell 'bcp "[D001Test.Restore].[dbo].[GeneralComments]" in "<DataFile>" -q -c -t "|_|" -r "...

How to import data from a view in another database (in another server) into a table in SQL Server 2000?

I was thinking about using bcp command to solve the user authentication, but does a bcp command capable to import to a table in my database? By the way, I am using SQL Server 2000 environment. Here's the code I have got so far: SET @Command = 'bcp "SELECT vwTest.* from [myserver\sql].test.dbo.vwTest" queryout dbo.Test -C ACP -c -r \...

Easy way to inspect BCP .dat file?

I'm getting BCP error "Unexpected EOF encountered in BCP data-file" during import, which is probably misleading. I strongly suspect that some field has been added to the table or there's some offending character is in the file. How would I go about inspecting the contents of .dat file visually? Are there any good hex viewers where I ca...

incoherence in bcp command execution

I execute a bcp command in 2 computer. The first computer has windows xp and second one has windows server 2003. when I execute command in first, the bcp run successfully but when I run this on second one, occur this error: Starting copy... SQLState = S1000, NativeError = 0 Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Code pag...

SQL Server Express 2005: How to import fixed width data using BCP

I’m trying to import fixed width data from text file into SQL Server Express using BCP. I have read some Microsoft’s web pages about this matter, but I haven’t got far with them. Can please give some examples or point to some good tutorials about this subject? ...

How to append EOF to file using Perl or Python?

I’m trying to bulk insert data to SQL server express database. When doing bcp from Windows XP command prompt, I get the following error: C:\temp>bcp in -T -f -S Starting copy... SQLState = S1000, NativeError = 0 Error = [Microsoft][SQL Native Client]Unexpected EOF encountered in BCP data-file 0 rows copied. Network packet size (by...

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 column and turn it in to an actual file. I would ideally like to be able to do this with BCP o...

Run a shell command with arguments from powershell script

Hello, I need to extract and save a some tables from a remote SQL database using bcp. I would like to write a powershell script to invoke bcp for each table and save the data. So far I have this script that creates the necessary args for bcp. However I can not figure out how to pass the args to bcp. Every time I run the script it just sh...