IBCPSession::BCPReadFmt (OLE DB)IBCPSession::BCPReadFmt (OLE DB)

适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 是Azure SQL 数据库Azure SQL DatabaseYesAzure SQL 数据库Azure SQL Database 是Azure SQL 托管实例Azure SQL Managed InstanceYesAzure SQL 托管实例Azure SQL Managed Instance 是Azure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics 是并行数据仓库Parallel Data Warehouseyes并行数据仓库Parallel Data Warehouse适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 是Azure SQL 数据库Azure SQL DatabaseYesAzure SQL 数据库Azure SQL Database 是Azure SQL 托管实例Azure SQL Managed InstanceYesAzure SQL 托管实例Azure SQL Managed Instance 是Azure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics 是并行数据仓库Parallel Data Warehouseyes并行数据仓库Parallel Data Warehouse

下载下载 OLE DB 驱动程序DownloadDownload OLE DB Driver

从格式化文件中读取每一列的格式信息。Reads format information for each column from the format file.

语法Syntax

  
HRESULT BCPReadFmt(   
      const wchar_t *pwszFormatFile);  

备注Remarks

可使用 BCPReadFmt 方法从格式化文件中读取数据,其中该文件指定数据文件中的数据格式 。The BCPReadFmt method is used for reading data from a format file that specifies the format of data in the data file. 此方法能够检测格式化文件的正确版本。This method is capable of detecting the correct version of the format file. 它可以自动检测格式化文件采用的是 xml 格式还是旧式的文本格式,并据此执行操作。It can automatically detect whether the format file is in xml or old style text format and behaves accordingly. OLE DB Driver for SQL Server BCP 支持的格式化文件版本为 6.0 版或更新版本。The format file versions supported by the OLE DB Driver for SQL Server BCP are version 6.0 or newer.

BCPReadFmt 方法在读取格式值之后,会相应调用 IBCPSession::BCPColumnsIBCPSession::BCPColFmt 方法。After the BCPReadFmt method reads the format values, it makes the appropriate calls to the IBCPSession::BCPColumns and IBCPSession::BCPColFmt methods. 用户不必分析格式化文件并发出上述调用。There is no need for the user to parse a format file and make these calls.

要保存格式化文件,请调用 IBCPSession::BCPWriteFmt 方法。To save a format file, call the IBCPSession::BCPWriteFmt method. 调用 BCPReadFmt 方法可引用保存的格式 。Calls to the BCPReadFmt method can reference saved formats. 或者,可使用大容量复制实用工具 (bcp) 将用户定义数据格式保存在可由 BCPReadFmt 方法引用的文件中 。Alternatively, the bulk-copy utility (bcp) can save user-defined data formats in files that can be referenced by the BCPReadFmt method.

IBCPSession::BCPControl 的 eOption 参数的 BCP_OPTION_DELAYREADFMT 值可修改 IBCPSession::BCPReadFmt 的行为。The BCP_OPTION_DELAYREADFMT value of the eOption parameter of IBCPSession::BCPControl modifies the behavior of IBCPSession::BCPReadFmt.

参数Arguments

pwszFormatFile [in]pwszFormatFile[in]
包含数据文件格式值的文件的路径和文件名。The path and file name of the file containing the format values for the data file.

返回代码值Return Code Values

S_OKS_OK
方法成功。The method succeeded.

E_FAILE_FAIL
出现访问接口特定的错误;要获取详细信息,请使用 ISQLServerErrorInfo 接口。A provider-specific error occurred, for detailed information use the ISQLServerErrorInfo interface.

E_OUTOFMEMORYE_OUTOFMEMORY
内存不足错误。Out of memory error.

E_UNEXPECTEDE_UNEXPECTED
意外调用了该方法。The call to the method was unexpected. 例如,在调用该方法之前,未调用 IBCPSession::BCPInit 方法。For example, the IBCPSession::BCPInit method was not called before calling this method.

另请参阅See Also

IBCPSession (OLE DB) IBCPSession (OLE DB)
执行大容量复制操作Performing Bulk Copy Operations