Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Latest commit

 

History

History
28 lines (19 loc) · 1.23 KB

071 SqlBulkCopy uses destination column encoding for strings.md

File metadata and controls

28 lines (19 loc) · 1.23 KB

71: SqlBulkCopy uses destination column encoding for strings

Scope

Edge

Version Introduced

4.5

Source Analyzer Status

Planned

Change Description

When inserting data into a column, SqlBulkCopy uses the encoding of the destination column rather than the default encoding for VARCHAR and CHAR types. This change eliminates the possibility of data corruption caused by using the default encoding when the destination column does not use the default encoding. In rare cases, an existing application may throw a SqlException exception if the change in encoding produces data that is too big to fit into the destination column.

  • Quirked
  • Build-time break

Recommended Action

Expect that SqlBulkCopy will no longer corrupt data due to encoding differences. If strings near the destination column's size limit are being copied, it may be necessary to either pre-encode data (to be copied to check that the data will fit in the destination column) or catch SqlExceptions.

Affected APIs

  • T:System.Data.SqlClient.SqlBulkCopy
  • M:System.Data.SqlClient.SqlBulkCopy.#ctor(System.Data.SqlClient.SqlConnection)

Category

Data

More information