bcp

Help me use powershell and bcp to load CSV into SQL Server

天大地大妈咪最大 提交于 2019-12-12 03:54:48
问题 I'm using bcp to load a table from a CSV exported from another table by someone else far far away, and have run into some issues. My original two problems: one exported field is an int that needs to end up in a varchar field, and another field needs to be populated with a static string. Well, the first is no big deal, and Chad's answer led me to the @{n='Col3';e={'ABC'}} syntax. But i'm stumbling around several issues getting the data loaded correctly. Sometimes a value might have no spaces,

Nested INNER JOIN with bcp

时光总嘲笑我的痴心妄想 提交于 2019-12-12 03:44:21
问题 So this query works fine without the nested SELECT/INNER JOIN. Not sure what is wrong with the nested SELECT, any ideas? So can't seem to get it to work in conjunction with bcp SELECT @SQLCmd = + 'bcp ' + '"SELECT ''<?xml version=""1.0"" encoding=""UTF-8""?>'' + ' + ' (SELECT CardId, Initials, firstname, lastname ' + ' (SELECT CardId, SetVal ' + ' FROM Business_data as bd ' + ' INNER JOIN Business_set as bs on bd.SetVal=bs.id ' + ' WHERE bd.CardID=ic.CardID ' + ' FOR XML PATH(''BD''), TYPE '

How does BCP queryout encode varbinary(max) and can I change the encoding?

社会主义新天地 提交于 2019-12-12 03:34:04
问题 I have a legacy system that has byte arrays of images(jpg) stored in the database in varbinary(max) columns. What is the default encoding being used by sql bcp to create the string that it writes to the flat file? Also, can I change the encoding? 回答1: When you output using bcp the default format is native or you can force that with the -n ( -N will also work since it stores noncharacter data as native). Kalman Toth's website has an example http://www.sqlusa.com/bestpractices/imageimportexport

How can I Import and export data using bcp command?

你。 提交于 2019-12-12 03:19:42
问题 I am Trying to import and export data using bcp tool but it was giving errors which are:- SQLState = 08001, NativeError = -1 Error = [Microsoft][SQL Server Native Client 10.0]SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. SQLState = 08001, NativeError = -1 Error = [Microsoft][SQL Server Native Client 10.0]A network-related or instance- specific error has occurred while establishing a connection to SQL Server. Serve r is not found or not accessible. Check

Simple SQL Bulk Insert not working

一世执手 提交于 2019-12-12 03:05:43
问题 I'm trying to create a simple Bulk Insert command to import a fixed width text file into a table. Once I have this working I'll then expand on it to get my more complex import working. I'm currently receiving the error... Msg 4866, Level 16, State 7, Line 1 The bulk load failed. The column is too long in the data file for row 1, column 1. Verify that the field terminator and row terminator are specified correctly. Obviously I have checked the terminator in the file. For test data I just typed

Using BCP to import data to SQL Server while preserving accents, Asian characters, etc

余生颓废 提交于 2019-12-12 02:58:40
问题 I'm trying to import a PostgreSQL dump of data into SQL Server using bcp. I've written a Python script to switches delimiters into '^' and eliminate other bad formatting, but I cannot find the correct switches to preserve unicode formatting for the strings when importing into SQL Server. In Python, if I print out the lines that are causing me trouble, the row looks like this with the csv module: ['12', '\xe4\xb8\x89\xe5\x8e\x9f \xe3\x81\x95\xe3\x81\xa8\xe5\xbf\x97'] The database table only

bcp with format file using command dos in windows

你离开我真会死。 提交于 2019-12-12 02:44:03
问题 I'am trying to import data into sql server table from a file using a format file. In fact I have 2 databases: a production database and a local database I want to insert some row of the table shipper of the production database in the local one. The table shipper don't have neither the same columns nor the same order of column in the 2 databases. That's why I used a file format to do my bcp. I generate file containing the rows I want to insert in my local database with the following commande

SQL Server 2008 R2: Best way to export BLOB and other column data out to the file system

≯℡__Kan透↙ 提交于 2019-12-12 02:14:01
问题 I have read some arts about BCP or CLR code that will export BLOBs to individual files on the hard drive, but I need to BCP or CLR out the entire table data together (meaning the other columns which are character or integer or datetime data need to come out as a whole) I need to make sure I can BCP/CLR the data back into the table and have the same linking between BLOBs and other column data. Any ideas? 回答1: I'm not sure if I understand what you're asking, so I'll try to cover two cases.

bcp Utility write to remote server?

北慕城南 提交于 2019-12-11 23:53:16
问题 According to some recommendations i use bcp Utility to write SQL server Table to .cvs file so i could later transfer the data to informix table with the same structure . My SQLServer Stored Procedure : ALTER PROCEDURE [dbo].[TestCVS] AS BEGIN declare @sql nvarchar(4000) select @sql = 'bcp "select * from ML..gmp4vacationbalance" queryout c:\ss\Tom.cvs -c -t, -T -S' + @@servername exec master..xp_cmdshell @sql END I have four questions concerning this procedure : 1- How to allow this procedure

SQL Server Express 2005: How to import fixed width data using BCP

主宰稳场 提交于 2019-12-11 18:31:20
问题 I’m trying to import fixed width data from text file into SQL Server Express using BCP. I have read some Microsoft’s web pages about this matter, but I haven’t got far with them. Can please give some examples or point to some good tutorials about this subject? 回答1: There's a wealth of material out there, and these two articles seem like a good start: http://www.devarticles.com/c/a/SQL-Server/An-Introduction-To-The-Bulk-Copy-Utility/ https://web.archive.org/web/1/http://blogs.techrepublic