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

In which layer should i create Sql Parameters for stored procedure with table value parameters using EF 5.0

I have created a data access layer(DAL) in my project and i am using Entity framework5 for CRUD operations. Also i have implemented repository and unit of work patterns in my data access layer. Now i have come up with a situation where i have to…
1
vote
1 answer

Is it possible to pass a table of rowtype from java to an oracle stored procedure?

I got this type in oracle: TYPE "RequestTable" IS TABLE OF "Requests"%ROWTYPE; I have used this type as an IN(or out) parameter of some stored procedures, like this: create or replace PROCEDURE …
SJ.Jafari
  • 1,236
  • 8
  • 27
  • 39
1
vote
1 answer

Table valued parameters - order of records to stored procedure

I have a stored procedure that accepts a table-valued parameter. I am passing a Datatable from my C# DAL. Are TVPs guaranteed to retain the order of rows when invoking the stored proc. My guess is that it should be (in which case this is a dumb…
Viking22
  • 545
  • 1
  • 7
  • 19
1
vote
2 answers

T-SQL Multi-Statement Table-Valued Function

I could really use some help writing a multi-statement table-valued function that uses the following logic: Accepts a varchar parameter as input If the parameter starts with A, run a select statement If no rows are returned, run a select…
1
vote
2 answers

Multiple String Search and Replace on SQL Server (for templates)

I have a database table that has template html, formatted as "text {var1} text {othervar}". I would like to apply the string substitutions in a more pragmatic way than: set @template = replace(@template, '{var1}', field.value); set @template =…
1
vote
1 answer

How call Table Values function from stored procedure

How to call function which returns table in stored procedure. I want to do use that returned table from function in stored procedure. How it is done ?
1
vote
1 answer

TVP vs loop for each parameter

I am in a situation where I need to do some comparison for some products that are in a shopping cart. The cart can have as many items as the user desires but the average over time is roughly 5-15 items per cart. My question is one about…
B-M
  • 1,231
  • 1
  • 19
  • 41
1
vote
1 answer

How can I call stored procedure returning 2 tables in a controller in mvc entity framework 4?

I have a stored procedure which returns 2 tables. How can I call this stored procedure from a controller in MVC. (I'm using Entity Framework 4) Stored procedure: create proc [dbo].[sp_list33](@emp dbo.list READONLY ) as select * from…
neetz
  • 140
  • 4
  • 11
1
vote
2 answers

How can I call stored procedure returning both a table and a return statement in a controller in mvc entity framework 4?

I have a stored procedure which returns a table as well as a return errorstate which is an int. How can I call this stored procedure from a controller in MVC. (I'm using Entity Framework 4) Stored Procedure : CREATE PROC [dbo].[sp_list24](@emp…
1
vote
1 answer

Table-valued parameter error in SQL Server

I'm working on a reporting module for a company project. Although we use an ORM for our application, I've decided to write stored procedures for the reports in anticipation of migrating to SSRS. These stored procedures require table-valued parameter…
user677526
1
vote
1 answer

Using table valued parameters with wildcards?

The scenario... I'm developing a web site in ASP.net and Visual Basic that displays product listings (hereafter referred to as "Posts") generated by the users. In this site, I have a search box that allows the user to find his post more easily. The…
Ross Brasseaux
  • 3,879
  • 1
  • 28
  • 48
1
vote
1 answer

Preserving non-inserted data for a record

I am experimenting with table valued parameters (TVP) and how to use them from C# code. One specific aspect of TVP is giving me trouble: When passing a list of data to the Stored Procedure and wanting to update that list after the data has come back…
1
vote
1 answer

Use dynamic SQL statement at SQL Server 2008 in tablevalue function

Is there any way to create a custom function that returns a table using a SQL statement that is created dynamically? So far I tried things like ALTER function [dbo].[Test2] (@Mandant smallint) RETURNS @Ergebnis TABLE ([Kundennummer]…
1
vote
5 answers

Delete multiple rows from a table in sql server with a single call from client application

Here is my requirement: I want to delete multiple rows of a table I have the list of all ids that needs to be deleted in the client app. All I want is to make just a single call from my C# client app to delete all these records. What I had…
Abey
  • 101
  • 2
  • 10
1
vote
1 answer

T-SQL UPSERT table with multiple values from TVP

I use SQL Server 2012, and T-SQL as query language. I need help updating/inserting multiple columns in [cross_function_user] using one ID value passed as a parameter (@userGroupID) and lots of function id's. They are List in C#, and passed to the…
Dr.Strangelove
  • 1,505
  • 1
  • 11
  • 12