bcp

BCP utility:“Copy direction must be either 'in', 'out' or 'format'”

杀马特。学长 韩版系。学妹 提交于 2019-12-10 17:19:55
问题 I get below mentioned error when I run BCP command for trusted connection: Copy direction must be either 'in', 'out' or 'format'. I tried searching MSDN, where it specifies that servername passed could be incorrect. The command I am trying is: bcp %SQL_database%..TABLE1 in \FileSERVER\file.dat -f\fileserver\Formats\file.fmt -eERR.txt -m1000000 -C -T RAW -S%SQL_server% When I pass a username and password instead of using the -T option, it works. The command is executed from command prompt by

Can SQL Server bcp in a file with Unix line endings?

余生长醉 提交于 2019-12-10 16:31:10
问题 I'm trying to use the SQL Server bcp utility to import a text file from a samba share. bcp is choking on the Unix line endings. I'm sure I could add an intermediate step, either on Unix or Windows, to change the line endings to Windows-style. But I would prefer to import the files from Unix without modification. Anybody know if there's a way to tell SQL Server bcp to look for Unix line endings? 回答1: You have to use a format file with bcp and specify the terminator as \n. The interactive

How to append EOF to file using Perl or Python?

落花浮王杯 提交于 2019-12-10 12:14:09
问题 I’m trying to bulk insert data to SQL server express database. When doing bcp from Windows XP command prompt, I get the following error: C:\temp>bcp in -T -f -S Starting copy... SQLState = S1000, NativeError = 0 Error = [Microsoft][SQL Native Client]Unexpected EOF encountered in BCP data-file 0 rows copied. Network packet size (bytes): 4096 Clock Time (ms.) Total : 4391 So, there is a problem with EOF. How to append a correct EOF character to this file using Perl or Python? 回答1: EOF is End Of

BCP import all files from a folder to database

 ̄綄美尐妖づ 提交于 2019-12-10 10:55:58
问题 BCP Import How to do BCP import with all files in a folder. folder file1.csv file2.csv Need to import both the files. bcp <tableName> in <filename> -t "^" -r "\n" -c -C 28591 -S <databaseinstance> -U <username> -P <password> Using the above BCP cmd, we can import only one file at a time. 回答1: simple BCP command import only single file. To achieve the above we need to use looping with the command. I have used the following command simple command. for /r %i in (*) do bcp <tablename> in %i -t "^

How to write using BCP to a remote SQL Server?

北城余情 提交于 2019-12-10 09:27:15
问题 I have a remote SQL Server with a hostname I am using to connect to. BCP suggests to use bcp DBName.dbo.tablename in C:\test\yourfile.txt -c -T -t However when I try this it does not connect to DBName as that is not a valid alias. I get native error 2. How to I run BCP but specify an internet / network address to connect to, not an MSSQL server name? 回答1: How to I run BCP but specify an internet / network address to connect to, not an MSSQL server name? You can specify the IP address (here

What is the best way to save XML data to SQL Server?

[亡魂溺海] 提交于 2019-12-09 16:17:54
问题 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, I tend to prefer to have most of my business logic in the C# code. I have seen a solution using SQLXMLBulkLoad, but it seemed to require fairly complex SQL code

bcp import error with xml format file and identity column

跟風遠走 提交于 2019-12-09 02:07:27
问题 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

Exporting PDF's from SQL Server DB and writing a Map to a Text File

陌路散爱 提交于 2019-12-08 11:48:04
问题 I need to write an application or Query to export a large amount of PDF's to file and create a delimited text file that shows where the files are and contains the ID of the record. what I was thinking about doing was using a console application that would write the entry to the text file after exporting the PDF from the DB, that way I would have all the information together when writing the Text File so that I could make sure that all the Data in the Delimited text file was accurate. at first

How to get the date format in windows batch file as 'yyyymmdd'?

断了今生、忘了曾经 提交于 2019-12-08 11:22:58
问题 I am writing a Windows Batch file and the batch file is supposed to output a file in a specific folder. I want the filename to be written as follows: filename-yyyymmdd.csv where yyyymmdd stands for the current date. My batch file codes stand as follows: cd:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn bcp "SELECT TOP 100 * FROM xxxx.dbo.xxxxx" queryout c:\test\csv\confirmed.csv -t, -c -S xxxx\xxxxx -U xxx -P xxxxxxxxxx set mydate=%date:~10,4%%date:~4,2%%date:~7,2% echo

using BCP to export stored procedure result in SQL Server 2008

六月ゝ 毕业季﹏ 提交于 2019-12-08 05:45:30
问题 Heyy, I'm trying to use BCP to export a SP result to a text file using this query: EXEC xp_cmdshell 'bcp "exec asmary..usp_Contract_SelectByEmpId -1,1" queryout "C:\test.txt" -w -C OEM -t$ -T -r ~ -S heba\HEBADREAMNET ' The output of this query is telling this error: Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near the keyword 'where'. even thought I'm sure that the stored procedure "usp_Contract_SelectByEmpId" is working correctly. Anyone faced that kind of