bcp

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 produce valid CSV - strings aren't encapsulated so you can't deal with any row that has a str...

Can a BCP version 8.0 format file have a column name that is a SQL keyword?

I have a format file where I want one of the columns to be "group". I'm auto-generating the format file and a client wants to upload a file with "group" as one of the columns. I could restrict it so they can't use SQL keywords, but then I need a function to determine if a column name is a SQL keyword, so I'd like to support the user be...

BCP out Error in SQL2000: SQLState = 37000, NativeError = 4060

Hi, I have created a proc that grabs all the user tables in a local DB on my machine. I want to be able to create a flat file of all my tables using BCP and SQL. Its a dummy database in SQL 2000 connecting through windows authentication. I have set my enviroment path variable in WinXP SP2. I have created new users to access the db, swi...

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 binary data back into a table of the same strucutre. here's some code. Export Command Line:...

SQL Server BCP insert additional columns

Hi My reuirement: Input File: 1,abc,xyx 2,def,mno 3,ghi,suv DB Table Structure: Col1 char col2 char col3 char col4 char col5 char Data in Table after BCP: col1 col2 col3 col4 col5 1 abc xyz ab xy 2 def mno de mn 3 ghi suv gh su Basically the col4 and col5 are calculated values from col2 and col3 v...

sql server bcp xml data

Hi I have a table which has a column which is of type xml. I have to extract data from this table and load the data into another environment. i am using bcp to extract and laod the target table but there are some special characters that is causing some issues when i bcp them into the target table. are there any workarounds thanks Ben ...

Successful Implementations of NAnt bcp (SQL Server) Task?

I am looking for either a NAnt Task for SQL Server bcp, or the file format for bcp native output. I supposed I could build a NAntContrib Task for bcp but I don't have time at the moment (Do we ever?). Has anybody strolled this path before? Advice? Thanks - Jon ...

How to save data from a semicolon delimited file using Bulk Insert in SQL Server 2005 and BCP 9?

Here is my sample data: 1;a;b;c;; 2;d;e;f;; 3;g;h;i;; 4;j;k;l;; 5;m;n;o;; 6;p;q;r;; Here is my sample format file (BCP 9): 9.0 7 1 SQLCHAR 0 0 "" 0 x Latin1_General_CI_AS 2 SQLCHAR 0 0 ";" 2 i Latin1_General_CI_AS 3 SQLCHAR 0 0 ";" 3 s Latin1_General_CI_AS 4 SQLCHAR 0 0 ";" 4 t Latin1_General_CI_AS 5 SQLCHAR 0 0 ";" 5 u Latin1_Genera...

What bcp format file that I'm gonna used to insert 59 columns?

First Observation, limitation with this BCP format file Data File: (Continuous up to three lines) 1;a;b;c;d;e;f;; 2;d;e;f;g;h;i;; 3;g;h;i;j;k;l;; 4;j;k;l;m;n;o;; 5;m;n;o;p;q;r;; 6;p;q;r;s;t;u;;What bcp format file that I'm gonna used to insert 59 columns? Format File: 9.0 9 1 SQLCHAR 0 0 "" 0 x "" 2 SQLCHAR 0 0 ";" 2 col1 Latin...

How do you use a binarywriter to write the correct MS SQL native format for the Money data type?

How do you use a binarywriter to write the correct MS SQL native format for the Money data type? I'd like to take a value in .net, read from a file as string representation of a decimal amount (actually an exported "Money" data type from SQL, but that is unimportant). How can I use a binary writer to write the value so that you can u...

How can I use the BCP Command in Linux?

I want to use the bcp command in Linux as the following: bcp "EasyCash.dbo.user" out "[EasyCash].[dbo].[user].dat" -q -c -t "<EOFD>" -r "<EORD>" -Usa -P123456 -S192.168.1.5 The message in Linux shows like that: -base bcp: command not found Can anyone solve my problem? ...

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 solutions that involve large complex stored procs--while I'm not entirely opposed to this,...

How to Export SSIS data on SQL Standard and Import with Bulk Insert on SQL Express?

I would like to use SSIS to create database table flat file exports then import them in to variously distributed SQL Express installs. As you may guess, SSIS is not available in the Express version. When I do the bulk insert, it errors with: Msg 4866, Level 16, State 8, Line 1 The bulk load failed. The column is too long in the data f...

Tool to do line content only compares

I'm working on a a tool to generate TSV files for import into a database using bcp.exe and I'd like to validate my output. I can do this by comparing the file I generate to the files produced by exporting using bcp from an existing database. My problem is that the ordering can sometimes be different between files. I'd like a tool that wi...

Exporting SQL Server data with redistributed components

I'm writing an application that is trying to bulk export data from a SQL Server database (with a given connection string) to a local file (in whatever format). Normally the sql server utility BCP.exe would be ideal, however, the bcp utility may not be available on the machine my app is running on. Also, bcp is not considered a redistri...

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 fields (except concatenating them to the field values, which is ugly). I guess I could do...

Copying large amounts of data into a SQL CE database

If I have a large amount of data in memory, what is the best way to copy it into a SQL CE table? The current technology stack is C#, ADO.net, and SQL CE. My initial idea was to do one INSERT statement for each row of data, but this is time-consuming. Is there an easier way? ...

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 FILEcontents: FirstName;LastName;Country;Age Roger;Mouthout;Belgium;55 SQL Person Table Columns: FName,LName,Country ...

Can't get windows task scheduler to run scheduled console application.

I have a console app that uses two batch files to decompress a zip file, take the xls which was decompressed convert it to CSV and BCP the data into a SQL table. I'd like to schedule this console app to run once a day. I set up windows task scheduler to run said app. I try to "test run" the task and don't get an error. I have the app wri...

BCP utility corrupts data

I am running a bulk copy of two columns of a table from one server to another. The table on the source side has about 8 columns, but I only need 2. The table on the destination side has 2 columns (the two that I need, both are of type int) Both databases are SQL Server 2005. Here's my two bcp commands: c:\> bcp "select c1, c2 from s...