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
-1
votes
1 answer

Copying CSV file to on-premise SQL Server -BCP utility C# .NET Core

I am trying to load a CSV file to on premise SQL Server, I tried to use BCP utility in my C# code, here is what I have done and facing below error. Note: I have created a SQL table name AzureBlob with 2 columns already with no data in it. static…
Auo
  • 399
  • 2
  • 5
  • 16
-1
votes
1 answer

Error in Importing Pipe delimited data with BCP in SQL Server

I am trying to import pipe delimited data with BCP in SQL server but getting error. I have tried all the possible solution on the internet but couldn't get through. Sample data - 1000004178|Valentin|FR12562062232|Valentin|Che St Georges| |…
-1
votes
1 answer

Is there any way to handle the NULL/NA from BCP data file for numeric database columns

I want to load a data file into the SQL Server database using the BCP command. The Data file has some data as NULL(string) or NA but the columns type in the database is numeric. e.g ABC|TEST DRUG…
-1
votes
1 answer

Is there any way we can resume file load from nth line in a bcp utility instead of loading the file from the beginning?

I'm loading a data file to a SQL server database using bcp utility. There are some scenarios where while loading huge files, the load fails at mid way due to connectivity issues. I can identify how many records are loaded in database. Assuming n…
Arun
  • 65
  • 1
  • 9
-1
votes
1 answer

How to create batch file and execute bcp command using C#?

I want to get data from all tables of specific database. I have generated few BCP statements in sql. Now i need to execute these bcp statements from windows service using batch file in c#. I have following bcp statements: bcp…
SHEKHAR SHETE
  • 5,964
  • 15
  • 85
  • 143
-1
votes
2 answers

How can I create native Sybase BCP file?

I have data in my program's memory, that I need to import into a database. For performance reasons I would like to do it via Sybase BCP, specifically using native file format. Challenge: I need to know what the native Sybase BCP file format is, and…
DVK
  • 126,886
  • 32
  • 213
  • 327
-1
votes
1 answer

How do you create an fmt file using the bcp command and only selecting a subset of columns from the target table?

I am creating .fmt files with the bcp command using the template below: bcp schema.dbo.table format nul -S servername\sqlserver-engine -f filename.fmt -c -T This command creates a tab separated file with all the columns from the target table along…
mikel
  • 3
  • 4
-1
votes
2 answers

Bulk Insert Concordance Formatted DAT File with FMT Format File Error

I'm using SQL Server 2017. I'm trying to BULK INSERT into SQL Server a number of .DAT files that are delimited with a Pilcrow (¶) for columns and a Lower Case Thorn (þ) for text (this is a common delimiter format among e-discovery platforms). Here…
Craig
  • 145
  • 1
  • 12
-1
votes
1 answer

bcp select with STUFF function to .json format

I have a table with 6 columns and need to convert that output to .json format and send output to .json format to a folder. I'm testing only with one column. When I execute the select statement I get the correct output; select'[' +STUFF((select ',{'+…
-1
votes
1 answer

Headers in xp_cmdshell bcp export (SQL Server)

I can't seem to find a way to retain the column headers using xp_cmdshell bcp to export a .csv or .txt file. Currently I'm using this code to export the tables to a txt file: SET @sqlsave = 'master.sys.xp_cmdshell ''bcp "SELECT * FROM…
Lore
  • 1
  • 1
-1
votes
1 answer

How to export a SQL table to a CSV file automatically in a query?

I want to export a SQL table to a CSV file automatically within a query. I've already accomplished to export a SQL table to a .CSV but the output was a TAB-separated file and without the column headers. How to make the output comma separated and…
SQL Shane
  • 115
  • 4
-1
votes
1 answer

BCP Utility - omit default values in import file

I have a table: CREATE TABLE [dbo].[EXTRACT]( ID int IDENTITY, CREATE_DTTM datetime default GETDATE() NOT NULL, CONTRACT_ID varchar(30) NOT NULL, ACCOUNT_NUMBER varchar(30) NOT NULL, EXCEPTION_REASON varchar(max), PRIMARY…
Igor
  • 569
  • 5
  • 24
-1
votes
2 answers

How to Pass Parameter to bcp command line in SQL

I have gone through many posts, but none seem to work, I keep getting an error. I first tried this : exec master..xp_cmdshell'bcp ClientDB.dbo.SparePartsPriceList_Temp_Export out ' + @OutPutFolder + '\' + @DealerType +'-XP006.txt -c -T -S…
AxleWack
  • 1,801
  • 1
  • 19
  • 51
-1
votes
1 answer

BCP Command on Shell (.sh file)

I have a .sh script that do this: bcp "EXEC SPName" queryout "test.csv" -k -w -t"," -S "$server" -U "$user" -P "$pass" The variables $server, $user and $pass are being read from a external config file. The problem is that the variables don't work…
tg_dev3
  • 171
  • 3
  • 18
-1
votes
1 answer

bcp dynamic query not accepting more than 4000 characters

While generating the XML ,I am using XP-CMDSHELL along with BCP.My query character length is more than the 4000 characters . Bcp only considering 4000 characters. kindly suggest the way. Note : query is not going to convert in sp or view
Vicky J
  • 1
  • 3