bcp

SQL Server: The bulk load failed. The column is too long in the data file for row 1, column 1

孤街浪徒 提交于 2019-12-01 08:39:13
Someone please help me here. Been looking at this for a couple of hours now but leading to nowhere. I created a table in SQL Express 2008 R2 using the following script: CREATE TABLE Features ( ID int not null identity(1,1 ), StopID varchar(10), Code int, Name varchar(100), Summary varchar(200), Lat real, Lon real, street varchar(100), city varchar(50), region varchar(50), postcode varchar(10), country varchar(20), zone_id varchar(20), the_geom geography CONSTRAINT [PK_Features] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW

SQL Server Bcp Export XML Format

[亡魂溺海] 提交于 2019-12-01 07:08:37
I have a stored procedure generating XML with FOR XML functionality. When I run the stored procedure, I get beautifully formatted XML as a result. When I try to export this result into a file with bcp declare @sql varchar(8000) select @sql = 'bcp "exec sp_ExportXml" queryout C:\Filename.xml -S (local) -T -w' exec master..xp_cmdshell @sql I get a badly formatted with line breaks inside the xml tags e.g. <Division>3</Divi sion> I am completely clueless, I tried several different parameters for bcp queryout but always getting the same result. Any ideas are highly appreciated! Thanks Bobby Is the

What will be BCP format for inserting a identity column

会有一股神秘感。 提交于 2019-12-01 01:46:12
问题 I am facing problem while I am trying to insert data to a table using BCP. The table has a identity column. I am taking input from a text file. Please let me know if there are any good solutions. Regards, Chayan 回答1: I needed to do the same thing and my colleague pointed out that you can use the -E switch on BCP to do this. From the docs... "-E Specifies that identity value or values in the imported data file are to be used for the identity column. If -E is not given, the identity values for

bcp import error with xml format file and identity column

人盡茶涼 提交于 2019-12-01 01:23:53
I created a table in SQL server like: CREATE TABLE [dbo].[ [myId] [smallint] IDENTITY(1,1) NOT NULL, [name] [nchar](10) NOT NULL, [value] [int] NOT NULL, CONSTRAINT [PK_metadado] PRIMARY KEY CLUSTERED ( [myId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] I want to import a file in my table using xml formater. I got a problem because my table had "myId". I think it's a bug in bcp because, if i don't add myId column, the importation works fine. File: Test 0010000290 Xml format file: <BCPFORMAT xmlns="http

Can I specify an input sql file with bcp?

依然范特西╮ 提交于 2019-11-30 23:18:36
问题 How can I specify an input sql file with a long query when using bcp? I tried using the -i option but it keeps complaining about a command-line error with no extra information. Is this possible? 回答1: As far as I'm concerned the BCP utility only supports Transact-SQL queries directly written to the command line. Ex: bcp "SELECT Name FROM AdventureWorks.Sales.Currency" queryout Currency.Name.dat -T -c According to its reference the "-i" option: Specifies the name of a response file, containing

Getting column names with BCP queryout

∥☆過路亽.° 提交于 2019-11-30 21:03:09
I need to BCP a table into a tab-delimited file, but I need the column names in the first record of the table. Question 1: Am I right that BCP does not have a switch for this? Question 2: If not, why? I tried to do the following: 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** The format file looks like this: 9.0 1 1 SQLCHAR 0 100 "\r\n" 1 Column_Names SQL_Latin1_General_CP1_CI_AS This

How to backup and restore sybase database tables using command line [closed]

一曲冷凌霜 提交于 2019-11-30 09:58:49
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . How can I backup my sybase tables and restore using command line? please help me with the command using bcp I have tried using sybase central GUI Thanks. 回答1: Since you didn't specify whether you are running on Windows or Unix I'll try to cover both. Unix bcp is located in $SYBASE/$SYBASE_OCS/bin/ Windows bcp is

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

╄→гoц情女王★ 提交于 2019-11-30 09:19:19
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 Paul Creasey Setting the row terminator in addition to the field terminator should do the trick 'bcp DBName..vieter out c:\test003.txt -c -T -t"\",\"" -r"\"\n\"" -S SERVER' This will likely work, but miss off the leading " for the first field of the first line, and perhaps the last field of the last line - I'm not sure, just

Unable to open BCP host data-file

不想你离开。 提交于 2019-11-30 08:17:34
Below is an example of the BCP Statement. I'm not accustomed to using BCP so your help and candor is greatly appreciated I am using it with a format file as well. If I execute from CMD prompt it works fine but from SQL I get the error. The BCP statement is all on one line and the SQL Server Agent is running as Local System. The SQL server, and script are on the same system. I ran exec master..xp_fixeddrives C,45589 E,423686 I've tried output to C and E with the same result EXEC xp_cmdshell 'bcp "Select FILENAME, POLICYNUMBER, INSURED_DRAWER_100, POLICY_INFORMATION, DOCUMENTTYPE, DOCUMENTDATE,

Getting column names with BCP queryout

谁说胖子不能爱 提交于 2019-11-30 05:28:44
问题 I need to BCP a table into a tab-delimited file, but I need the column names in the first record of the table. Question 1: Am I right that BCP does not have a switch for this? Question 2: If not, why? I tried to do the following: 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** The