Unable to use TVP as query input
See original GitHub issueProviding Table Value Parameter as input to query fails on sp_executesql
Expected behaviour:
The query to execute successfully and give the result of
Actual behaviour:
The query fails to execute due to an issue with sp_executesql
Example that works in raw tsql
CREATE TYPE MyAwesomeType AS TABLE (storeNbr INT);
DECLARE @tvp StoreNumberTableType
INSERT INTO @tvp
VALUES (1), (2)
exec sp_executesql N'SELECT * FROM @tvp', N'@tvp MyAwesomeType readonly', @tvp
Translated example that fails in node-mssql
const t = new sql.Table('MyAwesomeType');
t.columns.add('storeNbr', sql.Int);
t.rows.add(1);
t.rows.add(2);
const req = connection.request();
req.input('tvp', t);
return req.query(`SELECT * from @tvp`);
Configuration:
// paste relevant config here
Software versions
- NodeJS: 12.13.1
- node-mssql: 6.2.1
- SQL Server: Enterprise 2017
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
Unable to use Table-Valued Parameter (TVP) in query (node ...
I am attempting to export some data from SQL, store it and later compare that data to the result of the same query....
Read more >Not able to pass TVP as an input parameter to a Stored ...
I am trying to call a stored procedure which takes TVP(Table Valued parameter) as input parameter. const Sequelize = require('sequelize'); const ...
Read more >TVP Performance with high volume... - MSDN - Microsoft
I have .NET application that passes parameters to a stored procedure. One of the parameters is a table valued parameter(TVP) which is with ......
Read more >Table-Valued Parameters in SQL Server - SQLShack
Table-Valued Parameters aka TVPs are commonly used to pass a table as a parameter into stored procedures or functions. They are helpful in...
Read more >Using Table-Valued Parameters in SQL Server and .NET
Let's first look at how to use TVPs in T‑SQL without involving a client. To be able to declare a TVP, you first...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@dhensby Looks like this is an issue with the way the underlying tediousjs library handles executing raw queries. Will close this issue and continue looking into this issue at the tedious layer. Will link the PR here, if I am able to figure out an acceptable fix.
I will look into it and see if I can figure it out to submit a PR. Thank you.