question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EREQUEST:4012 An invalid tabular data stream (TDS) collation was encountered when SP executed

See original GitHub issue

I am trying to send TVP from nodejs to SQL server stored procedure along with other parameters. When the stored procedure is executed the error is triggered.

Expected behaviour:

When i try to execute from the query from SQL server it works fine. I expect the same to happen.

DECLARE	@return_value int
DECLARE @priceList LocationPricingTableTyp
DECLARE @primKey uniqueidentifier
	 SET @primKey = NEWID();
INSERT INTO @priceList
SELECT @primKey, 55676123, 12.0, 15.0,'young','summary';

EXEC	@return_value = [dbo].[sp_LocationMaster_Create]
		@LocationId = 55676123,
		@Language = 'aen',
		@IsActive = 1,
		@TblLocationPrice = @priceList
SELECT	'Return Value' = @return_value

GO

Actual behaviour:

When i executing from the nodejs

    const LocationPricingTableTyp = new sql.Table()
    LocationPricingTableTyp.columns.add('LocationId', sql.Int)
    LocationPricingTableTyp.columns.add('LowestPrice', sql.Decimal)
    LocationPricingTableTyp.columns.add('HighestPrice', sql.Decimal)
    LocationPricingTableTyp.columns.add('PriceType', sql.VarChar)
    LocationPricingTableTyp.columns.add('Summary', sql.Text)
    // Add rows
    LocationPricingTableTyp.rows.add(777,12.0,15.0,'young','summary')

          SQLrequest.input('LocationId'				         ,sql.Int      ,itemobj.baseId)	
          SQLrequest.input('Keywords'					,sql.Text     ,itemobj.Keywords)		
          SQLrequest.input('IsDeleted'				        ,sql.Bit      ,true)		
          SQLrequest.input('IsActive'					        ,sql.Bit      ,true)
          SQLrequest.input('TblLocationPrice'                              ,LocationPricingTableTyp)
          SQLrequest.execute("sp_LocationMaster_Create", (err, recordset) => {
            if (err){
            
              console.log('Not added due to following error')
              console.log(err)
             
            }else{ 
            // send records as a response
            console.log('successfully added to Master');
                                 
            }
            });

Error:“An invalid tabular data stream (TDS) collation was encountered.”

Software versions

  • NodeJS: 8.9.4
  • mssql: 4.2.2
  • SQL Server studio: 17.5

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13

github_iconTop GitHub Comments

1reaction
deepanigicommented, Oct 26, 2018

@deepanigi the fist thing you need to do is provide us with code to replicate the problem.

At the moment the code you’re provided is not code that can replicate the problem because it contains material errors that would prevent it from running.

Please provide a working code sample that reproduces the issue. I have mentioned the script and stored procedure below.

Table Type Declared tt

Nodejs Script File nodejs.txt

var sql = require("mssql");
var guid = require("guid");
let pool;
const config = {
    user: 'hello',
    password: 'password',
    server: 'database.windows.net',
    database: 'DB_DEV',

    options: {
        encrypt: true,
    },
};

const LocationPricingTableTyp = new sql.Table();
LocationPricingTableTyp.columns.add('Key', sql.UniqueIdentifier);
LocationPricingTableTyp.columns.add('LocationId', sql.Int);
LocationPricingTableTyp.columns.add('LowestPrice', sql.Decimal);
LocationPricingTableTyp.columns.add('HighestPrice', sql.Decimal);
LocationPricingTableTyp.columns.add('PriceType', sql.VarChar);
LocationPricingTableTyp.columns.add('Summary', sql.Text);
// Add rows// Values are in same order as columns.
let key = guid.raw();
LocationPricingTableTyp.rows.add(key, 777, 12.0, 15.0, 'young', 'summary');
DBLocationMaster().then(function (value) {

});


async function DBLocationMaster() {
    try {
        pool = await sql.connect(config);


        let SQLrequest = await pool.request();

        SQLrequest.input('LocationId', sql.Int, '123');
        SQLrequest.input('Language', sql.VarChar, 'en');
        SQLrequest.input('IsActive', sql.Bit, true);
        SQLrequest.input('TblLocationPrice', LocationPricingTableTyp);
        SQLrequest.execute("sp_LocationMaster_Create", (err, recordset) => {
            if (err) {
                console.log('Location not added due to following error');
                console.log(err);
            }
            else {
                console.log('Location successfully added to Master');
            }
        });

    } catch (err) {
        // ... error checks
        console.log(err);
    }
}

StoredProcedure

SP.txt

1reaction
willmorgancommented, Oct 24, 2018

Hi, which version of node-mssql are you using?

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQLServer An invalid tabular data stream (TDS) collation was ...
P.S. I am using Retry pattern for retrying upon connection reset. java.util.concurrent.ExecutionException: com.microsoft.sqlserver.jdbc.
Read more >
KB2563924 - FIX: "The incoming tabular data stream (TDS ...
Cause. This issue occurs because the ODBC driver does not send the data length of the SQL_NULL_DATA value to the table-valued parameter.
Read more >
TDS Error - Devart Forums
Since upgrading to Delphi Berlin, I'm now getting the error 'An invalid tabular data stream (TDS) collation was encountered' on SDAC version ...
Read more >
[MS-TDS]: Tabular Data Stream Protocol - NET
Packet Data Token and Tokenless Data Streams . ... TDS Type Restrictions . ... When a stored procedure is executed by the server, ......
Read more >
The incoming tabular data stream (TDS) protocol stream is ...
The incoming tabular data stream (TDS) protocol stream is incorrect error occurs when running a query using the Connect for ODBC SQL Server ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found