denisenkom / pytds

Python DBAPI driver for MSSQL using pure Python TDS (Tabular Data Stream) protocol implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

davidhozic opened this issue · comments

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

@davidhozic Explanation as in #123. Wordaround provided as well.

Closing as duplicate of #123