table-valued-parameters

EntityFrameWork and TableValued Parameter

China☆狼群 提交于 2019-12-02 18:30:14
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 arounds and few saying it's not supported in current versions. Does any one know a better approach or

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

本小妞迷上赌 提交于 2019-12-02 17:49:50
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 resulted in the error System.ArgumentException: There are no records in the SqlDataRecord enumeration. To

Auto Increment SQL Value

做~自己de王妃 提交于 2019-12-02 12:53:55
In the infinte wisdom of the global DBA at a firm I am working at right now he has created a table that takes an int as an ID field, but does not auto increment the number. I am passing up a table valued parameter from .Net because it has roughly 100 or more rows of data that are being passed up at any one time and I dont want to kill the application, hammer the network or the SQL Server. So this is my stored procedure CREATE PROCEDURE sp_Insert_Supporting_Error_Info (@tvp [dbo].udt_CEQZW READONLY) as begin INSERT INTO CEQZW ERROR_VAR_ID, ERROR_ID, ERROR_VAR_TYPE_CD, ERROR_VAR_VALUE) SELECT

How to improve the code of stored procedure with inner join to possible empty tvp

我是研究僧i 提交于 2019-12-02 08:10:43
I want to improve the code of the following stored procedure. I want to join it into single select statement. Can you purpose a better way? CREATE PROCEDURE [dbo].[pr_FinDocument_Filter] @finDocIdForFilter [dbo].[GuidList] READONLY, @filteredSid nvarchar(64), @filteringOffsetInDay int AS BEGIN IF (@filteredSid is null or @filteringOffsetInDay is null) BEGIN RAISERROR(N'arguments must have a value', 15, 1); END IF EXISTS (SELECT 1 FROM @finDocIdForFilter) BEGIN SELECT fin_doc_extra.docId FROM [CpsOther].[dbo].[FinDocumentExtra] AS fin_doc_extra INNER JOIN @finDocIdForFilter AS fin_doc_for

Create and Pass a Table-Valued Parameter in a Single Line

↘锁芯ラ 提交于 2019-12-01 17:58:28
Using SQL Server 2012, is it possible to eliminate the need to declare a table-valued parameter (TVP) just to pass it into a stored procedure? Below is a really simple example of a stored procedure (SP) that takes a TVP and a working example to execute that SP where I have to declare the TVP, populate it and then pass it into the SP. I would like to be able to simply pass in the population criteria directly to the EXEC call. Is this possible? Scenario Setup: -- Create a sample Users table CREATE TABLE Users (UserID int, UserName varchar(20)) INSERT INTO Users VALUES (1, 'Bob'), (2, 'Mary'), (3

DataTable with a byte[] field as parameter to a stored procedure

末鹿安然 提交于 2019-11-30 19:16:22
I've been reusing this method of using a DataTable as a parameter to a stored procedure and it's been working great. This is the simplified working code: using (dbEntities dbe = new dbEntities()) { var dt = new dataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Message"); dt.Columns.Add("CreatedOn", typeof(DateTime)); foreach (var row in randomDataSource) { dt.Rows.Add( row.id, row.message, DateTime.Now ); } var tableType = new SqlParameter("tableType", SqlDbType.Structured); tableType.Value = dt; tableType.TypeName = "[dbo].[RandomTableType]"; dbe.ExecuteStoreCommand( "EXEC [dbo].[SaveTable]

Performance of User-Defined Table Types in SQL Server

流过昼夜 提交于 2019-11-30 07:09:25
问题 We have been using User-Defined Table Types to pass a list of integers to our stored procedures. We then use these to join to other tables in our stored proc queries. For example: CREATE PROCEDURE [dbo].[sp_Name] ( @Ids [dbo].[OurTableType] READONLY ) AS SET Nocount ON SELECT * FROM SOMETABLE INNER JOIN @Ids [OurTableType] ON [OurTableType].Id = SOMETABLE.Id We have seen very poor performance from this when using larger datasets. One approach we've used to speed things up, is the dump the

Table-Valued Parameter in Stored Procedure and the Entity Framework 4.0

牧云@^-^@ 提交于 2019-11-30 05:57:02
问题 I have a stored procedure in SQL Server 2008 called 'GetPrices' with a Table-Valued Parameter called 'StoreIDs'. This is the type i created for this TVP: CREATE TYPE integer_list_tbltype AS TABLE (n int) I would like to call the SP from my Entity Framework. But when I try to add the Stored Procedure to the EDM, i get the following error: The function 'GetPrices' has a parameter 'StoreIDs' at parameter index 2 that has a data type 'table type' which is not supported. The function was excluded.

DataTable with a byte[] field as parameter to a stored procedure

对着背影说爱祢 提交于 2019-11-30 03:53:07
问题 I've been reusing this method of using a DataTable as a parameter to a stored procedure and it's been working great. This is the simplified working code: using (dbEntities dbe = new dbEntities()) { var dt = new dataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Message"); dt.Columns.Add("CreatedOn", typeof(DateTime)); foreach (var row in randomDataSource) { dt.Rows.Add( row.id, row.message, DateTime.Now ); } var tableType = new SqlParameter("tableType", SqlDbType.Structured); tableType.Value

Passing Table Valued parameter to stored procedure across different databases

一曲冷凌霜 提交于 2019-11-29 09:42:51
I'm using SQL Server 2008 . How can I pass Table Valued parameter to a Stored procedure across different Databases , but same server? Should I create the same table type in both databases? Please, give an example or a link according to the problem. Thanks for any kind of help. In response to this comment (if I'm correct and that using TVPs between databases isn't possible): What choice do I have in this situation? Using XML type? The purist approach would be to say that if both databases are working with the same data, they ought to be merged into a single database. The pragmatist realizes