@@ -1729,40 +1729,36 @@ private void getDestinationMetadata() throws SQLServerException {
1729
1729
if (null != destinationTableMetadata ) {
1730
1730
rs = (SQLServerResultSet ) destinationTableMetadata ;
1731
1731
} else {
1732
- stmt = (SQLServerStatement ) connection .createStatement (ResultSet .TYPE_FORWARD_ONLY ,
1733
- ResultSet .CONCUR_READ_ONLY , connection .getHoldability (), stmtColumnEncriptionSetting );
1732
+ stmt = (SQLServerStatement ) connection .createStatement (ResultSet .TYPE_FORWARD_ONLY , ResultSet .CONCUR_READ_ONLY , connection .getHoldability (), stmtColumnEncriptionSetting );
1734
1733
1735
1734
// Get destination metadata
1736
- rs = stmt .executeQueryInternal (
1737
- "sp_executesql N'SET FMTONLY ON SELECT * FROM " + escapedDestinationTableName + " '" );
1735
+ rs = stmt .executeQueryInternal ("sp_executesql N'SET FMTONLY ON SELECT * FROM " + escapedDestinationTableName + " '" );
1738
1736
}
1739
1737
1740
- destColumnCount = rs .getMetaData ().getColumnCount ();
1738
+ int destColumnMetadataCount = rs .getMetaData ().getColumnCount ();
1741
1739
destColumnMetadata = new HashMap <>();
1742
1740
destCekTable = rs .getCekTable ();
1743
1741
1744
- if (!connection .getServerSupportsColumnEncryption ()) {
1745
- metaDataQuery = "select collation_name from sys.columns where " + "object_id=OBJECT_ID('"
1746
- + escapedDestinationTableName + "') " + "order by column_id ASC" ;
1747
- } else {
1748
- metaDataQuery = "select collation_name, encryption_type from sys.columns where "
1749
- + "object_id=OBJECT_ID('" + escapedDestinationTableName + "') " + "order by column_id ASC" ;
1750
- }
1742
+ metaDataQuery = "select * from sys.columns where " + "object_id=OBJECT_ID('" + escapedDestinationTableName + "') " + "order by column_id ASC" ;
1751
1743
1752
1744
try (SQLServerStatement statementMoreMetadata = (SQLServerStatement ) connection .createStatement ();
1753
- SQLServerResultSet rsMoreMetaData = statementMoreMetadata .executeQueryInternal (metaDataQuery )) {
1754
- for (int i = 1 ; i <= destColumnCount ; ++i ) {
1745
+ SQLServerResultSet rsMoreMetaData = statementMoreMetadata .executeQueryInternal (metaDataQuery )) {
1746
+ for (int i = 1 ; i <= destColumnMetadataCount ; ++i ) {
1755
1747
if (rsMoreMetaData .next ()) {
1756
1748
String bulkCopyEncryptionType = null ;
1757
1749
if (connection .getServerSupportsColumnEncryption ()) {
1758
1750
bulkCopyEncryptionType = rsMoreMetaData .getString ("encryption_type" );
1759
1751
}
1760
- destColumnMetadata .put (i , new BulkColumnMetaData (rs .getColumn (i ),
1761
- rsMoreMetaData .getString ("collation_name" ), bulkCopyEncryptionType ));
1752
+ // Skip computed columns
1753
+ if (!rsMoreMetaData .getBoolean ("is_computed" )) {
1754
+ destColumnMetadata .put (i , new BulkColumnMetaData (rs .getColumn (i ), rsMoreMetaData .getString ("collation_name" ),
1755
+ bulkCopyEncryptionType ));
1756
+ }
1762
1757
} else {
1763
1758
destColumnMetadata .put (i , new BulkColumnMetaData (rs .getColumn (i )));
1764
1759
}
1765
1760
}
1761
+ destColumnCount = destColumnMetadata .size ();
1766
1762
}
1767
1763
} catch (SQLException e ) {
1768
1764
// Unable to retrieve metadata for destination
0 commit comments