bcp

I/O error while reading BCP format file

a 夏天 提交于 2019-12-23 08:49:44
问题 Today I created a new staging table and a BCP .fmt file. I created some test data and attempted to run the BCP utility from the command line: I've got about 20 different format files and staging tables from previous work and this is the first time I have encountered this error. How can I fix this error? Please note, I have added my solution below, but if you have other answers, please add them in. The answer was so quirky/obscure that I think it may help others. 回答1: Basically, this one was

Export query result to csv in UTF-8

好久不见. 提交于 2019-12-23 05:40:29
问题 I would like to export query result to csv file in utf-8. Now i export to csv in this way: DECLARE @cmd varchar(1000) SET @cmd = 'bcp "select * from table" queryout "d:\textfile.csv" -w -T -t; -Slocalhost' EXEC xp_cmdshell @cmd How to make file be in UTF-8? 回答1: SQL Server does not support code page 65001 (UTF-8 encoding). reference You need to add -w parameter in bcp utility to specify the encoding is UTF16 . 回答2: I am sure you have long since solved your problem but as this is still open

Using Sybase ASE BCP to a Remote Server

梦想的初衷 提交于 2019-12-23 03:38:18
问题 I am using BCP to export/import data sometimes to remote servers where i cannot login into the OS, only connect to the DB. I have success with using BCP to connect to a server like this: bcp mytester.dbo.MyTable in MyTable.bcp -S Sybase157 -U sa -P SyAdmin -n This of course only works becuase Sybase157 is defined in my sql.ini. My question: a) Is it possible to sidestep the whole sql.ini thing and just do something like -S mydb.server.com or -S 123.123.123.123 and if not.... b) what do i need

Does sybase 15 support the bcp api in java?

我的未来我决定 提交于 2019-12-22 05:30:08
问题 A long time ago I figured out that bcp is just a little C program that calls the special bit of the sybase client api to do mass data moving into the database. It lies cheats and steals and skips check constraints all in the name of speed. Great, I'm all for it. In sybase 12 I noticed that the api was exposed in the C client library, but not the java one. I've been looking but I haven't found anything that says they've yet implemented it in the sybase 15 java client library. Does anybody know

Output XML Files with encoding UTF-8 using SQL Server

夙愿已清 提交于 2019-12-20 03:21:55
问题 I have a query that generates XML files and loads them to FTP with <?xml version="1.0"?> . I need to switch encoding to UTF-8 as follows: <?xml version="1.0" encoding="utf-8"?> I can do it manually in the text editor. But cannot do it in SQL Server. I also read this article but that did not contribute in finding solution for the issue. https://docs.microsoft.com/en-us/sql/relational-databases/xml/create-instances-of-xml-data My code: USE [Audit_DBA] GO SET ANSI_NULLS ON GO SET QUOTED

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

瘦欲@ 提交于 2019-12-18 16:45:20
问题 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: create 4 named pipes split 1 file into 4 streams, writing each stream to a separate named pipe read from 4 named pipes into 4 tables w/ bcp or BULK INSERT The closest

How do I use BCP or Sql Server Management Studio to get BLOB data out of Sql Server?

这一生的挚爱 提交于 2019-12-18 02:50:04
问题 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 or management studio if possible. I have tried BCP, but for some reason when I try and pull out an office document Word thinks it's corrupt. Here's what I've

how to export sql data to csv using bcp

流过昼夜 提交于 2019-12-17 20:52:40
问题 I use simple code declare @sql varchar(8000) select @sql = 'bcp ExcelAnalysis.dbo.ClearDB out c:\csv\comm.txt -c -t, -T -S '+ @@servername exec master..xp_cmdshell @sql but this code export all my table, but i need only some fields and conditions like: declare @sql varchar(8000) select @sql = 'bcp SELECT ,[vl] ,[data] ,[URL] ,[parse] ,[Strata] ,[Id] FROM [ExcelAnalysis].[dbo].[ClearDB] where [data]> "01.05.2017" and NOT [vl] ="mag"and NOT [vl] ="Maxximo" out c:\csv\status.txt -c -t, -T -S '+

export table to file with column headers (column names) using the bcp utility and SQL Server 2008

☆樱花仙子☆ 提交于 2019-12-17 08:25:54
问题 I have seen a number of hacks to try to get the bcp utility to export column names along with the data. If all I am doing is dumping a table to a text file what is the most straightforward method to have bcp add the column headers? Here's the bcp command I am currently using: bcp myschema.dbo.myTableout myTable.csv /SmyServer01 /c /t, -T 回答1: The easiest is to use the queryout option and use union all to link a column list with the actual table content bcp "select 'col1', 'col2',... union all

export table to file with column headers (column names) using the bcp utility and SQL Server 2008

巧了我就是萌 提交于 2019-12-17 08:25:13
问题 I have seen a number of hacks to try to get the bcp utility to export column names along with the data. If all I am doing is dumping a table to a text file what is the most straightforward method to have bcp add the column headers? Here's the bcp command I am currently using: bcp myschema.dbo.myTableout myTable.csv /SmyServer01 /c /t, -T 回答1: The easiest is to use the queryout option and use union all to link a column list with the actual table content bcp "select 'col1', 'col2',... union all