bcp

Unprintable characters in bcp.exe output

别说谁变了你拦得住时间么 提交于 2019-12-25 09:37:29
问题 I want is to dump three MSSQL Server tables using a batch job. I searched around and found bcp is highly recommended for this kind of work. Looking at the documentation, it seemed what I wanted was to dump the entire table, because I wanted all the data, not a subset. I am using the following command to extract data from the first table. bcp glmaster out d:\ftp_root\data_xfer\glmaster.txt -n -d mu_live -t"," -S munis -U <user> -P <pwd> with various combinations of -n or -n and -C, and

Custom column name for bcp queryout SQL Server

被刻印的时光 ゝ 提交于 2019-12-25 09:29:43
问题 I want to rename the column name in the select clause of a bcp queryout command.I've tried the below variations and none of them work.I want to rename the first and third column to email_address and id respectively. I am calling the bcp command in a batch script. bcp "select email as 'email_address', first_name, p_id as 'id' from table_name" queryout 15Days.txt -c -Sservername -Uusername -Ppassword -t, bcp "select email as [email_address], first_name, p_id as [id] from table_name" queryout

Why my bcp query out not work in sql server?

一笑奈何 提交于 2019-12-25 04:16:04
问题 I'm new in sql server and want to save select query into the csv file using with bcp query out for that purpose write this query: declare @cmd as nchar(50) SET @cmd = 'bcp select *from [behzad].[dbo].[behzad] queryout "d:\spt_values.dat" -U behbeh -P beh1368421 ' EXEC master..XP_CMDSHELL @cmd but i get this output: How can i solve this problem?thanks. 回答1: As you are using queryout your source must be a query. As a query has got blanks, you have to quote it: Further more your @cmd nchar(50)

Export MSSQL database to MS Access .accdb file

倾然丶 夕夏残阳落幕 提交于 2019-12-25 04:13:44
问题 I have a Microsoft SQL Server database which is updated with data regularly. I would like to store this database with all tables (and preferrably relationsships) to a new Microsoft Access (.accdb) file using C#. SQL Management Studio is installed on the system so I think one solution could be to invoke BCP (http://msdn.microsoft.com/en-us/library/ms162802.aspx) from the code, but I haven't figured out how to use it correctly in this case. I guess there are much better ways doing it without

How to read text file into @table variable using bcp command

瘦欲@ 提交于 2019-12-25 02:26:47
问题 I have below text file having different words inside it: My aim is to insert only 4 character words from the text file into a table variable which is @temp , using bcp command. So, at the end, the table variable @temp will look like below: 回答1: Create a table where you will store the data coming from your file: create table import(WORDS nvarchar(100)) Import data from file with bcp into the table created in the first step: bcp [test].[dbo].[import] in d:\test.txt -c -T Declare @table variable

Bulk insert, Cannot bulk load. Unknown version of format file

跟風遠走 提交于 2019-12-24 22:19:49
问题 I'm having problems importing data exported using a more recent version of the bcp utility. I need my exported data to be compatible with SQL server 2012. It is my understanding that I need to add the -V110 option when exporting data. However, even if I add the -V110 to the bcp command I always get version 12.0 (which is my bcp version) on the FMT file. Here is a sample of my bcp call: bcp [DB].[dbo].[Table1] format nul -c -f "E:\TMP\DATA\Table1.FMT" -V110 -S [SERVER] -t , -T Does anybody

Switch to include column headers in bcp

六月ゝ 毕业季﹏ 提交于 2019-12-24 16:29:29
问题 I don't see in the documentation how to include column headers with in my csv-type output file. I'm sure this is a duplicate, But I can't seem to find one that leads to my exact need. Here's my command: bcp "select * from MYDB.dbo.MyTable" queryout "C:\outputfile.csv" -c -t"," -r"\n" -S ServerName -T -k -E 回答1: A standard well known hack is to select the column names union all make them part of the query itself and export that, something like this...... bcp "SELECT 'ColName1','ColName2',

BCP Error: columns may be skipped only when copying into the Server

让人想犯罪 __ 提交于 2019-12-24 01:09:50
问题 When I issue this command (It looks silly but it works): BCP "declare @colnames varchar(max); select @colnames=coalesce (@colnames+char(9), '') + Column_Name from db.information_Schema.columns where table_name='table1' order by ordinal_position; select @colnames" queryout Table1_Columns.tsv -S?? -U?? -P?? -f** -e** I get this error: [Microsoft][SQL Native Client]Host-file columns may be skipped only when copying into the Server The format file is: 9.0 1 1 SQLCHAR 0 100 "\r\n" 1 Column_Names

BCP - Invalid character value for cast specification when importing to table with IDENTITY column

∥☆過路亽.° 提交于 2019-12-23 18:36:27
问题 I am trying to load a file from UNIX to SQL Server. When I run the BCP getting the error below, but I was able to load the same file when I changed the datatype to Char. Command used: -- bcp [SQLAAA].[APP_XXX].[ACTIVITY_V1] in /home/XXX_ACTIVITY.txt -c -S xddb001 -e /home/ERRORS.log -t "|" -r "\n" -U test12 -P test12 Source file: 222|2017-12-27|Y|ABC|2017-12-27|ABC|2017-12-27 255|2018-01-04|N|ABC|2018-01-04|ABC|2018-01-04 Error Message: @ Row 1, Column 7: Invalid character value for cast

Boost BCP doesn't output any files?

守給你的承諾、 提交于 2019-12-23 09:44:24
问题 I'm trying to use the Boost Copy (BCP) utility to pull the normal_distribution class out of Boost. However, when I do bcp normal_distribution ./my_normal_distribution_dir , nothing appears in the my_normal_distribution_dir directory. Here's some more detailed background on the environment that I'm doing this in: On Mac OS 10.7, I downloaded the Boost 1.50 and untared source files. In the top-level Boost directory, I did ./bootstrap.sh . Then, I did ./bjam ./tools/bcp , which produced a bcp