INF: Using BCP & .FMT File to Read in Only Specified ColumnsLast reviewed: March 12, 1997Article ID: Q50636 |
The information in this article applies to:
- Microsoft SQL Server for OS/2 version 4.2 - Microsoft SQL Server version 4.2 You can read in only specified columns by using BCP and making modifications to the format file with some restrictions. You can modify the .FMT file to enable a bulk copy of data from only specific columns. The remaining columns will be filled with NULLS and the column format must be set up to allow NULLs when the table is created. To do this, do the following:
4.0 4 1 SYBINT4 0 4 "" 1 a 2 SYBINT4 0 4 "" 2 b 3 SYBINT4 0 4 "" 3 c 4 SYBINT4 0 4 "" 4 dTo modify this file to read in only the first and last columns of data, you need to change the file to the following (if you are using Microsoft SQL Server version 4.2, substitute 4.2 for 4.0 in the first line of this example):
4.0 2 1 SYBINT4 0 4 "" 1 a 2 SYBINT4 0 4 "" 4 dThe important changes are made on the second line, which specifies the number of descriptors to follow, and the column specifiers, which are the numbers 1 and 4 in the next-to-last column. The actual names of the columns(a,d) are not important to the process. Once the .FMT file has been modified and saved, perform a BCP call that reads back into the database (or a different or newly created database), specifying this format file with the -f option.
|
Additional query words: 4.20 Windows NT
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |