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
0
votes
1 answer

View vs TableValued Function vs SubQuery

I have a scenario where i need to join with 3 tables to get the value for one field for second field join with 4 tables for third field join with 3 tables all above joins are inner and if data exist the value of my field would be "Y" else "N" to…
Radhi
  • 6,289
  • 15
  • 47
  • 68
0
votes
0 answers

Passing table-valued parameter for IN operator

How can I pass string parameter with table-value for stored procedure in SQL Server (using c#). My code: C# SqlParameter tvpParam = cmd.Parameters.AddWithValue( "@inoper", "'New York','Boston'"); tvpParam.SqlDbType =…
michael24B
  • 293
  • 1
  • 6
  • 20
0
votes
2 answers

SQL Server Parameter Table Values inside SQL query

I made a function that takes a varchar (IP address) and returns table values (city, country, time_zone...) ALTER function [dbo].[GQuery2](@ipAddress varchar(16)) returns @t table ( [country_name] [nvarchar](64) , [region_name]…
teter
  • 1,468
  • 1
  • 14
  • 19
0
votes
1 answer

Pass String into @Parameter from a VS report

I did ask a question about this but still cant work out how to get this working, ive looked at some examples where people have used functions, table variables, create types and cant really get any working so wondering if someone could help and maybe…
0
votes
1 answer

SQL Server 2012 Insert a Set and Get all PK Values?

I have a sproc that takes a TVP, the input has 6,000 rows. The current code copies the TVP into a temp table, iterates RBAR over the temp table to insert a row on a real table, gets the Identity/PK value from the insert, updates the temp table with…
Snowy
  • 5,942
  • 19
  • 65
  • 119
0
votes
0 answers

MiniProfiler and SQL Server Table Valued Parameters

We use SQL Server for our database, and sometimes want to pass table valued parameters to stored procedures. Our current method of doing this involves (C#): // datatable is System.Data.DataTable // command is System.Data.Common.DbCommand var…
0
votes
0 answers

Pass a table valued parameter to a stored procedure called by OPENROWSET

I'm trying to debug an application issue and I need to compare the results of two stored procedures. From digging around on here I found out about OPENROWSET, which works great when the params can be hard coded but when the param is a table valued…
stardotstar
  • 318
  • 2
  • 18
0
votes
1 answer

Table valued parameters - time out

I have implemented Table valued parameters that gets populated from C# program and uses stored procedure to finally store in tables. I found that if I send in 75 records at a time, I do not get time out or else I do. How can I insert more records at…
newbieCSharp
  • 181
  • 2
  • 22
0
votes
1 answer

Does passing a Table to a Stored Procedure incur multiple database calls?

I have a large set of data. Now i am passing that data in the form of concatenated string with delimiters. In the stored procedure i am parsing the string and storing responses to table. Is this is the best approach OR passing Table to stored…
Siva
  • 109
  • 1
  • 6
0
votes
0 answers

accessing Table valued parameters

I have a question as to how to send multiple table parameters to a stored procedure. create table dbtest.Company_verified([CompanyAddr] varchar NULL, [ID] [int] NULL primary key, [Address1] varchar NULL, [city] varchar…
newbieCSharp
  • 181
  • 2
  • 22
0
votes
1 answer

Cannot convert datatype nvarchar to numeric

I import data from from an Excel file into a SQL Server database with the following query. The Excel file has all values as string types (' before every cells). I get this error when I import it."Cannot convert datatype nvarchar to numeric" If I…
0
votes
2 answers

How to convert datatype before Importing Excel file to Sql database

Here I have this Import from excel file to sql database class. It was working correctly till now but as my excel file cells are all strings type , So when Importing , the datatype does not match as sql database. How to convert it to their respective…
0
votes
1 answer

Update query (Parameterized query,Table valued parameters)

I have a SQL TABLE Inventory Having many columns two of which are LocalSKU (pk) varchar(200) NOT NULL QOH int And an EXCEL DATA having only two columns LocalSKU and QOH I want to implement a query where I want to match both data according to…
0
votes
1 answer

SQL counting total rows from temporary table in a table valued function

I need the number of total rows inserted in @t, if @total equals 1. How can I do that? ALTER FUNCTION [dbo].[myfunction] ( @ID int = NULL, @years int = NULL, ,@total BIT = 0 ) RETURNS @t TABLE ( RowNum int, ID int, years…
Miguel Mas
  • 547
  • 2
  • 6
  • 23
0
votes
1 answer

Inserting values from Table Valued Parameter into a database table

How would I insert values from a table valued parameter into a table as it is right now it doesnt work. Which is the best way of doing this? ALTER PROCEDURE [dbo].[SaveDomainObject] @Fields dbo.TemplateFieldsAsSqlParameter READONLY AS BEGIN INSERT…
Arianule
  • 8,811
  • 45
  • 116
  • 174