Questions tagged [table-valued-parameters]

Table-Valued Parameters is a feature introduced in SQL SERVER 2008. In earlier versions of SQL SERVER it is not possible to pass a table variable in stored procedure as a parameter, but in SQL SERVER 2008 we can use Table-Valued Parameter to send multiple rows of data to a stored procedure or a function without creating a temporary table or passing so many parameters.

Table-valued parameters are like parameter arrays in OLE DB and ODBC, but offer more flexibility and closer integration with Transact-SQL. Table-valued parameters also have the benefit of being able to participate in set-based operations

Transact-SQL passes table-valued parameters to routines by reference to avoid making a copy of the input data.

http://msdn.microsoft.com/en-us/library/bb510489.aspx

Table-valued parameters are declared by using user-defined table types. You can use table-valued parameters to send multiple rows of data to a Transact-SQL statement or a routine, such as a stored procedure or function, without creating a temporary table or many parameters. Table-valued parameters are like parameter arrays in OLE DB and ODBC, but offer more flexibility and closer integration with Transact-SQL. Table-valued parameters also have the benefit of being able to participate in set-based operations. Transact-SQL passes table-valued parameters to routines by reference to avoid making a copy of the input data. You can create and execute Transact-SQL routines with table-valued parameters, and call them from Transact-SQL code, managed and native clients in any managed language.

411 questions
1
vote
1 answer

Are SQL Server 2008 Table Valued Parameters vulnerable to SQL injection attacks?

I have been investigating Table-Valued Parameters in SQL Server 2008, and I've discovered that when passing such a parameter to a stored procedure, a query such as the following is sent to the database server: declare @p1 dbo.MyTypeName insert into…
Mark
  • 11,257
  • 11
  • 61
  • 97
1
vote
0 answers

Passing a Object to sql server Stored Procedure (as TVP)

I have scenario , where I pass the entity (Object) with other dependent child entity to the Stored procedure and the SP should create/delete/update the tables respective for that entity in the Database. Eg - Entity - Person ChildEntity - Skills,…
Ish Tech
  • 239
  • 1
  • 2
  • 12
0
votes
1 answer

Efficiently filter data in a table-valued parameter in a stored procedure

I've got a table-valued type as a parameter to a stored procedure, with anything up to thousands of rows in it. I perform several operations on this stored procedure (currently a MERGE and an INSERT), but before those I want to filter the contents…
thecoop
  • 45,220
  • 19
  • 132
  • 189
0
votes
1 answer

How is a Table Valued Parameter passed into Merge statement getting Duplicate Key error on an empty table?

I am sending a Table Valued Parameter into an MS SQL Server 2008 R2 stored procedure from C# code. The error I receive is: "Violation of PRIMARY KEY constraint 'PK_Example.ExampleTable'. Cannot insert duplicate key in object…
0
votes
1 answer

Insert List of dictionary data into SQL Server using pytds tvp

I would like to implement list of dict data to be loaded into SQL Server DB using pytds tablevalueparams tvp in my python code. \ I tried below mentioned code and it's not working as expected. def call_sproc(val): server = 'my_server' user =…
0
votes
0 answers

Oracle - How to send query result as parameter to a function

I need to create a function that get 2 string and a table parameters to store them i a table like that create table Result( Id NUMBER GENERATED BY DEFAULT AS IDENTITY, RefCode VARCHAR2 (10), Notes VARCHAR2 (4000), DynamicContent…
gt.guybrush
  • 1,320
  • 3
  • 19
  • 48
0
votes
0 answers

Problem with Table Valued Parameter SQL server and Python Pyodbc

I've created a test table, then a Type Table and then a SP: CREATE TABLE prueba ( id int IDENTITY, datos varchar (20), nums NUMERIC (10,2) CONSTRAINT PK_PRUEBA PRIMARY KEY (id) ) CREATE TYPE dbo.pruebatable AS TABLE ( datos…
0
votes
1 answer

Is a table-valued parameter (UDT) data entry specific to a user session?

I use the user-defined table parameter to track the keyed in values and pass it to a stored procedure. Syntax works fine. No problem with it. Question: Does it creates multiple instances at the same time for individual sessions? Does it maintain…
0
votes
1 answer

Insert values into table from TVP and variable

I have an input TVP @_inputTvp TableType Readonly and local variable declare @_localVar varchar I know how to insert TVP to a table, and variable value to a table. But now I have 2 source of data (TVP and local variable) to insert to table.…
Haze
  • 3
  • 3
0
votes
0 answers

Calling table value MSSQL stored procedure from python

I want to call a MSSQL Stored Procedure from Python which takes table value as a parameter, and which was earlier triggered from API by passing   { "data": [{"xyz": 340, "abc": 0, "ijk": '296202302M13', "files": [{ …
0
votes
1 answer

Can a stored proc be declared with a table-valued parameter along with other parameters in SQL Server?

Edit: one of the comments mentions "misuse" of parentheses around the parameter. I'm attaching a screen-capture of the Microsoft documentation page showing those parentheses; and my stored proc wouldn't compile without them. I am trying to use a…
Tim
  • 8,669
  • 31
  • 105
  • 183
0
votes
1 answer

Stored procedure with CASE and WHERE coming from a table value parameter

In a SQL Server stored procedure, can I use two separate columns from a table-valued parameter (TVP) in both the CASE and WHERE clauses? In my TVP, I have two columns like so: CREATE TYPE tt_Index AS TABLE ( …
0
votes
1 answer

SQL Update in Batches using Table Type Parameters

I am trying to update a table using table type parameter. Currently I am using the below query. But I would like to perform update in batches having batch size as one of the parameters. Kindly help. ALTER PROCEDURE UPDATEStatus @Ids int , …
0
votes
0 answers

TVP parameter in wildfly server with Jndi datasource, fail to cast or unwrap statements

I have a stored procedure in my SQL Server that take an argument of TVP type. After my finding I need to use SQLServerPreparedStatement to pass TVP in SP. Application Tech Stack Spring Boot Java 11 SQL Server Wildfly Server 21.0.1 JNDI Data…
0
votes
0 answers

JDBI how to bind table valued parameter for stored procedure

I have a stored Procedure which takes table valued parameter as input. I am using JDBI in my SpringBoot Application. How do I bind TVP to stored procedure. This is my Stored Procedure. CREATE PROCEDURE exampleSP @country char(2), …