Interactive bcp

If data is being copied between Microsoft® SQL Server™ and other programs, such as another database program, the default data type formats (native, character, or Unicode) may not be compatible with the data structures expected by the other programs. Therefore, the bcp utility allows more detailed information regarding the structure of the data file to be specified.

If the -n, -c, -w, or -N parameters are not specified, the bcp utility prompts for further information interactively on each column of data being copied:


Note Interactive mode is not available when using the BULK INSERT statement.


The bcp utility provides default values at each of these prompts based on the SQL Server data type of the source or destination column. Accepting the default values supplied by bcp at these prompts produces the same result as native format (-n), and provides a way to bulk copy data out of other programs for later reloading into SQL Server.

A format file can be created to store the responses of the prompts for each field in the data file, allowing the same responses to be reused without having to enter them again. The format file can be used to provide all the format information required to bulk copy data to and from SQL Server. A format file provides a flexible system for writing data files that requires little or no editing to conform to other data formats, or for reading data files from other software.

For example, the command to bulk copy the publishers table interactively to the Publ.txt file is:

bcp pubs..publishers out publ.txt -Sservername -Usa -Ppassword

  

A series of four prompts appears for each column of the publishers table, with the bcp-supplied default displayed in brackets. This example is for the pub_id column in the publishers table only.

Enter the file storage type of field pub_id [char]:
Enter prefix length of field pub_id [0]:
Enter length of field pub_id [4]:
Enter field terminator [none]:

  

Pressing ENTER accepts the supplied default. To specify a value other than the default, enter the new value at the command prompt.

See Also

Using the bcp Format File

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.