The bcp utility, BULK INSERT, and INSERT ... SELECT * FROM OPENROWSET(BULK...) all support the use of a specialized format file that stores format information for each field in a data file. A format file might also contain information about the corresponding SQL Server table. The format file can be used to provide all the format information that is required to bulk export data from and bulk import data to an instance of SQL Server.
Format files provide a flexible way to interpret data as it is in the data file during import, and also to format data in the data file during export. This flexibility eliminates the need to write special-purpose code to interpret the data or reformat the data to the specific requirements of SQL Server or the external application. For example, if you are bulk exporting data to be loaded into an application that requires comma-separated values, you can use a format file to insert commas as field terminators in the exported data.
SQL Server 2005 and later versions support two kinds of format files: XML format files and non-XML format files. Non-XML format files are supported by earlier versions of SQL Server; XML format files were new in SQL Server 2005.
The bcp utility is the only tool that can generate a format file. For more information, see Creating a Format File. For more information about format files, see Format Files for Importing or Exporting Data.
Note: |
|---|
|
In cases when a format file is not supplied during a bulk export or import operations, the user can choose to override the default formatting at the command line.
|