-
Notifications
You must be signed in to change notification settings - Fork 453
Closed
Description
Driver version
13.2.1.jre11
SQL Server version
Microsoft SQL Azure (RTM) - 12.0.2000.8
Client Operating System
Windows 11
JAVA/JVM version
21
Table schema
CREATE TABLE dbo.Products
(
ProductID int IDENTITY (1,1) NOT NULL,
QtyAvailable SMALLINT,
InventoryValue AS QtyAvailable * UnitPrice PERSISTED
UnitPrice MONEY
);Problem description
When trying to do a bulk insert using useBulkCopyForBatchInsert for a table with a computed persisted column, it will fail with an error message like:
"Column 3 is invalid. Please check your column mappings."
Digging a bit deeper it is caused by this check:
mssql-jdbc/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
Lines 2095 to 2099 in caef383
| } else if (0 > cm.destinationColumnOrdinal || destColumnCount < cm.destinationColumnOrdinal) { | |
| MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidColumn")); | |
| Object[] msgArgs = {cm.destinationColumnOrdinal}; | |
| throw new SQLServerException(form.format(msgArgs), SQLState.COL_NOT_FOUND, DriverError.NOT_SET, | |
| null); |
In the above table it would have a destinationColumnOrdinal of 4 but destColumnCount of 3, leading to that check failing.
Expected behavior
Either have that limitation documented in the known limitations or ignore computed persisted columns in that check.
Metadata
Metadata
Assignees
Labels
No labels