diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java index b868ba5fd..b47e294c7 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java @@ -2622,7 +2622,6 @@ else if (4 >= bulkScale) * Writes sql_variant data based on the baseType for bulkcopy * * @throws SQLServerException - * an exception */ private void writeSqlVariant(TDSWriter tdsWriter, Object colValue, ResultSet sourceResultSet, int srcColOrdinal, int destColOrdinal, int bulkJdbcType, boolean isStreaming) throws SQLServerException { @@ -2634,7 +2633,7 @@ private void writeSqlVariant(TDSWriter tdsWriter, Object colValue, ResultSet sou int baseType = variantType.getBaseType(); byte[] srcBytes; // for sql variant we normally should return the colvalue for time as time string. but for - // bulkcopy we need it to be a timestamp. so we have to retrieve it again once we are in bulkcopy + // bulkcopy we need it to be timestamp. so we have to retrieve it again once we are in bulkcopy // and make sure that the base type is time. if (TDSType.TIMEN == TDSType.valueOf(baseType)) { variantType.setIsBaseTypeTimeValue(true); @@ -2672,7 +2671,6 @@ private void writeSqlVariant(TDSWriter tdsWriter, Object colValue, ResultSet sou tdsWriter.writeReal(Float.valueOf(colValue.toString())); break; - case MONEY4: case MONEY8: // For decimalN we right TDSWriter.BIGDECIMAL_MAX_LENGTH as maximum length = 17 // 17 + 2 for basetype and probBytes + 2 for precision and length = 21 the length of data in header @@ -2682,6 +2680,13 @@ private void writeSqlVariant(TDSWriter tdsWriter, Object colValue, ResultSet sou tdsWriter.writeSqlVariantInternalBigDecimal((BigDecimal) colValue, bulkJdbcType); break; + case MONEY4: + writeBulkCopySqlVariantHeader(21, TDSType.DECIMALN.byteValue(), (byte) 2, tdsWriter); + tdsWriter.writeByte((byte) 38); + tdsWriter.writeByte((byte) 4); + tdsWriter.writeSqlVariantInternalBigDecimal((BigDecimal) colValue, bulkJdbcType); + break; + case BIT1: writeBulkCopySqlVariantHeader(3, TDSType.BIT1.byteValue(), (byte) 0, tdsWriter); tdsWriter.writeByte((byte) (((Boolean) colValue).booleanValue() ? 1 : 0)); @@ -2786,8 +2791,9 @@ private void writeSqlVariant(TDSWriter tdsWriter, Object colValue, ResultSet sou case GUID: length = colValue.toString().length(); writeBulkCopySqlVariantHeader(9 + length, TDSType.BIGCHAR.byteValue(), (byte) 7, tdsWriter); - // since while reading collation from sourceMetaData in GUID we don't read collation, because we are - // reading binary, but in writing it we are using char, so we need to get the collation. + // since while reading collation from sourceMetaData in guid we don't read collation, cause we are + // reading binary + // but in writing it we are using char, we need to get the collation. SQLCollation collation = (null != destColumnMetadata.get(srcColOrdinal).collation) ? destColumnMetadata .get(srcColOrdinal).collation : connection.getDatabaseCollation(); variantType.setCollation(collation);