INF: Using BCP When Data Is Within Quotation MarksLast reviewed: June 16, 1997Article ID: Q73182 |
The information in this article applies to:
- Microsoft SQL Server versions 4.2 for OS/2 - Microsoft SQL Server versions 4.2
SUMMARYThis article describes how to customize the bulk copy program (BCP) format file to strip off unwanted quotation marks around the character strings in the data file.
MORE INFORMATIONIt is possible to customize the BCP format file to strip off quotation marks that surround character strings in the user's ASCII data file. This process requires modifying the terminators to include a backslash+quotation mark (\") to interpret the quotation mark as a literal. If the first field in the data file is within quotation marks, you must add a new line to the BCP format file to dispose of the first quotation mark. This example explains how to use BCP in the data file to exclude the quotation marks:
Data File"John","Doe",33,"New York" "Jane","Doe",31,"Seattle"
Format File4.0 41 SYBCHAR 0 12 "," 1 F_NAME 2 SYBCHAR 0 12 "," 2 L_NAME 3 SYBCHAR 0 4 "," 3 AGE 4 SYBCHAR 0 12 "\r\n" 4 BIRTH_PLACEPerform the numbered steps below to modify the format file to remove the quotation marks:
4.0 5 1 SYBCHAR 0 1 "" 0 FIRST_QUOTE 2 SYBCHAR 0 12 "\",\"" 1 F_NAME 3 SYBCHAR 0 12 "\"," 2 L_NAME 4 SYBCHAR 0 4 ",\"" 3 AGE 5 SYBCHAR 0 12 "\"\r\n" 4 BIRTH_PLACENOTE: The first line of the BCP.FMT refers to the version of the program. When running the version 1.1 or 1.11 of BCP this value is 4.0. In SQL Server 4.2 this value is 4.2. For similar examples with Microsoft SQL Server version 4.21a, 6.0 and 6.5, please see the following article(s) in the Microsoft Knowledge Base:
ARTICLE-ID: Q132463 TITLE : INF: Using BCP When Data is in Quotation Marks |
Additional query words: 4.20 quotes Windows NT
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |