denisenkom / pytds

Python DBAPI driver for MSSQL using pure Python TDS (Tabular Data Stream) protocol implementation
MIT License
190 stars 52 forks source link

TableValuedParam - OperationalError when row with null attribute is followed by a row with non null attribute #137

Closed davidhozic closed 11 months ago

davidhozic commented 2 years ago

When using pytds.TableValuedParam and cursor.callproc, if a row with a null atrribute inside the table is folowed by a row with a non null value for the same attribute, the remote procedure call will return the following error:

OperationalError('The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Table-valued parameter 1 (""), row 6, column 2: Data type 0xE7 has an invalid data length or metadata length. The data for the table-valued parameter 6 doesn\'t conform to the table type of the parameter. SQL Server error is: 8037, state: 30')

This error is avoided if the non null attribute row appears before the null one

takoau commented 1 year ago

@davidhozic Explanation as in https://github.com/denisenkom/pytds/issues/123. Wordaround provided as well.

denisenkom commented 11 months ago

Closing as duplicate of #123