![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
- Text Qualifier = Double Quote |
|
Hi, If there a method to format the bcp out so that it handles both commas and double quotes? To explain: I have the same problem with dts that I have with bcp. When I try to import descriptions that contain either double quotes or commas, I receive a SQLState = 22001 Sting data, right truncation. I could make the field larger than the field that goes in by two characters, but if I have both a comma and a double quote (inches), I'll need to increase the size of the field more. It seems like that solution is poor because there is no way, short of doubling the field size, that I can be sure it is adequate. I think adding the -q option might work for the quotes???? But what will make the commas import? OUT Context: C:\>bcp quoteupdate.dbo.vnewparts out c:\integrator\partslist.bcp -n -T Starting copy... 1000 rows successfully bulk-copied to host-file. Total received: 1000 1498 rows copied. Network packet size (bytes): 4096 Clock Time (ms.): total 2031 -- Quack, I wouldn't be asking this if I were anything but... |
#3
| |||
| |||
|
|
Let me add the following: In a post I found on this (http://www.examnotes.net/archive79-2002-8-54521.html) there was a suggestion to surround each field with double quotes, but there is also some very strange syntax in the post which I do not understand. It does explain the problem this Quack is having at the moment. snip - Text Qualifier = Double Quote bcp does not recognize text qualifiers. They are just more characters as far as bcp is concerned. That is why you are getting an error message because the fields in the field including the quotes are too large for the receiving columns. If you want to keep the quotes you will need to use a format file that looks like this: 8.0 9 1 SQLCHAR 0 1 "\"" 0 first_quote "" 2 SQLCHAR 0 10 "\"," 1 exceptionid "" 3 SQLCHAR 0 7 ",\"" 2 severity "" 4 SQLCHAR 0 1 "\"," 3 followupperiod "" 5 SQLCHAR 0 12 "," 4 followupqty "" 6 SQLCHAR 0 12 "," 5 leaddays "" 7 SQLCHAR 0 6 ",\"" 6 isactive "" 8 SQLCHAR 0 100 "\",\"" 7 followupattr "" 9 SQLCHAR 0 255 "\"\r\n" 8 description "" snip If the post actually has an answer for the Quack, the Quack can't tell because the Quack has no idea what the above syntax refers to. It looks good and feels like an answer but it doesn't help much. Quack (duck not, quack for sure) "Quack" wrote: Hi, If there a method to format the bcp out so that it handles both commas and double quotes? To explain: I have the same problem with dts that I have with bcp. When I try to import descriptions that contain either double quotes or commas, I receive a SQLState = 22001 Sting data, right truncation. I could make the field larger than the field that goes in by two characters, but if I have both a comma and a double quote (inches), I'll need to increase the size of the field more. It seems like that solution is poor because there is no way, short of doubling the field size, that I can be sure it is adequate. I think adding the -q option might work for the quotes???? But what will make the commas import? OUT Context: C:\>bcp quoteupdate.dbo.vnewparts out c:\integrator\partslist.bcp -n -T Starting copy... 1000 rows successfully bulk-copied to host-file. Total received: 1000 1498 rows copied. Network packet size (bytes): 4096 Clock Time (ms.): total 2031 -- Quack, I wouldn't be asking this if I were anything but... |
![]() |
| Thread Tools | |
| Display Modes | |
| |