table-valued-parameters

What permission do I need to use an SQL Server Table Valued Parameter (TVP) as a stored proc parameter?

非 Y 不嫁゛ 提交于 2019-12-10 04:01:42
问题 I'm using SQL Server 2008 R2 and I've created a TVP that I want to use as a parameter to a stored proc but I get a message saying that it can't be found or I don't have permission. I can use the TVP in a script or in the body of the stored proc, but when I try to use it as a parameter I get the error. Any thoughts? Edit: For clarification, the error I'm getting is on the creation of the stored proc 回答1: In order for a caller to use a PROC with a table valued parameter, you'll need to

How can I use a Table-Valued Parameter to insert multiple rows and then return their IDs?

浪尽此生 提交于 2019-12-07 14:32:05
问题 In my application, I have a large of number (100+) of rows that I need to insert into the database. Once they get inserted into the database, I need to insert their children, which have a foreign key reference back to the children. I'm wondering if there's a way to write a stored procedure that can insert all of those rows and return their IDs back to my application? 回答1: You have tagged your question with table-value-parameters - you can pass one these to the stored procedure for inserting

Accessing stored procedures with robconery / massive?

一世执手 提交于 2019-12-07 02:20:12
问题 Another great article by Rob on the Massive ORM. What I haven't been able to find is references on how to access stored procedures. SubSonic had some issues with the overhead of using ActiveRecords, so I preferred to do data access with stored procedures, still using the SubSonic ORM. What I haven't yet seen is outright support for things like SQL Server's TVP's in an ORM, so I modified SubSonic (shameless plug) to support them. Is it possible to access SQL Server sprocs with Massive.

Conversion of the nvarchar value '3001822585' overflowed an int column

非 Y 不嫁゛ 提交于 2019-12-05 10:16:04
I use following to import Excel file to SQL Server. The Excel file has all the values as string. I am able to import the file except Barcode , SalePrice and Price2 . I get error Conversion of the nvarchar value '3001822585'(barcode) overflowed an int column Code: SqlCommand sqlcmd = new SqlCommand (@"MERGE Inventory AS target USING (SELECT LocalSKU, ItemName, QOH, Price, Discontinued,Barcode, Integer2 ,Integer3, SalePrice, SaleOn, Price2 FROM @source) AS Source ON (Source.LocalSKU = target.LocalSKU) WHEN MATCHED THEN UPDATE SET ItemName = source.ItemName, Price = source.Price, Discontinued =

Pass table value param to stored procedure using PetaPoco

隐身守侯 提交于 2019-12-04 20:31:37
问题 For while I am trying to call SQL Server 2008 R2 stored procedure using PetaPoco. My stored procedure accepts a table valued parameter. How I can call the stored procedure in petapoco with table value param? Here what I am trying to do: var db = new PetaPoco.Database("repikaciskaBaza"); DataTable table = new DataTable(); DataColumn id = table.Columns.Add("id", type: typeof(Int32)); for (int i = 0; i < 10;i++ ) { DataRow row = table.NewRow(); row["id"] = i; table.Rows.Add(row); } var param =

Problems with table-value parameter performance

好久不见. 提交于 2019-12-04 17:02:28
问题 I don't know whether this is an issue with how I'm using them or Microsoft's implementation, but SQL 2008 table-value parameters are painfully slow. Generally if I need to use a TVP it's because I've got lots of records - currently they appear to be unusably slow for anything more than the fewest records. I'm calling them in .Net like this: // get the data DataTable data = GetData(); com.CommandText = "sprocName" // create the table-value parameter var tvp = com.Parameters.AddWithValue("data"

sql server 2008 table valued parameters linq2sql

╄→尐↘猪︶ㄣ 提交于 2019-12-04 11:50:54
Has anybody experimented with these. Is this supported? Table Value parameters aren't supported yet in LINQ to SQL. There's a few posts about this on Microsoft's MSDN forums: DbType.Structured not available SQL Server 2k8.User Defined Table Type. Mapping between DbType 'Structured' and Type 'System.Object' The second link refers to Entity Framework, but the underlying issue is the same. I actually had to try this myself. :0 It does not seem to be supported. I get this error when adding a stored procedure using a tvp parameter into the dbml file DBML1005: Mapping between DbType 'Structured' and

Binding empty list or null value to table valued parameter on a stored procedure (.net)

半城伤御伤魂 提交于 2019-12-04 07:51:37
问题 I have created a stored procedure that takes a table valued parameter that is a table with a single column of type int. The idea is to simply pass a list of ids into the store procedure and allow the sp to work with the data. However, in the case where there is no data to pass in, I am encountering problems (things work correctly when I have data). I am converting a List to an IEnumerable, and binding that to the table valued parameter for the sp. I have tried to bind an empty List, which

Passing parameter of type 'object' in table-valued parameter for sql_variant column

吃可爱长大的小学妹 提交于 2019-12-03 23:43:30
问题 I have a table-valued parameter in SQL Server 2012 defined as: CREATE TYPE [dbo].[TVP] AS TABLE ( [Id] [int] NOT NULL, [FieldName] [nvarchar](100) NOT NULL, [Value] [sql_variant] NOT NULL ) I call it in C# with code that looks roughly like the following: var mdItems = new DataTable(); mdItems.Columns.Add("Id", typeof(int)); mdItems.Columns.Add("FieldName", typeof(string)); mdItems.Columns.Add("Value", typeof(object)); mdItems.Rows.Add(new object[] {2, "blah", "value"}); //'value' is usually a

EntityFrameWork and TableValued Parameter

限于喜欢 提交于 2019-12-03 05:13:28
问题 I'm trying to call a stored procedure from EntityFramework which uses Table-value parameter. But when I try to do function import I keep getting a warning message saying - The function 'InsertPerson' has a parameter 'InsertPerson_TVP' at parameter index 0 that has a data type 'table type' which is currently not supported for the target .NET Framework version. The function was excluded. I did a initial search here and found few posts which says It's possible in EntityFrameWork with some work