table-valued-parameters

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

时光怂恿深爱的人放手 提交于 2019-11-28 11:17:56
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. Is there any workaround this? Any thoughts? Fabio Since you can't use a table parameter, try passing

Passing Table Valued parameter to stored procedure across different databases

自古美人都是妖i 提交于 2019-11-28 03:21:50
问题 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. 回答1: 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

Is it possible to use `SqlDbType.Structured` to pass Table-Valued Parameters in NHibernate?

99封情书 提交于 2019-11-27 18:12:28
I want to pass a collection of ids to a stored procedure that will be mapped using NHibernate. This technique was introduced in Sql Server 2008 ( more info here => Table-Valued Parameters ). I just don't want to pass multiple ids within an nvarchar parameter and then chop its value on the SQL Server side. Pawel Kupis My first, ad hoc, idea was to implement my own IType . public class Sql2008Structured : IType { private static readonly SqlType[] x = new[] { new SqlType(DbType.Object) }; public SqlType[] SqlTypes(NHibernate.Engine.IMapping mapping) { return x; } public bool IsCollectionType {

Performance of bcp/BULK INSERT vs. Table-Valued Parameters

纵然是瞬间 提交于 2019-11-27 06:11:08
I'm about to have to rewrite some rather old code using SQL Server's BULK INSERT command because the schema has changed, and it occurred to me that maybe I should think about switching to a stored procedure with a TVP instead, but I'm wondering what effect it might have on performance. Some background information that might help explain why I'm asking this question: The data actually comes in via a web service. The web service writes a text file to a shared folder on the database server which in turn performs a BULK INSERT . This process was originally implemented on SQL Server 2000, and at

Is it possible to use `SqlDbType.Structured` to pass Table-Valued Parameters in NHibernate?

烈酒焚心 提交于 2019-11-27 04:15:45
问题 I want to pass a collection of ids to a stored procedure that will be mapped using NHibernate. This technique was introduced in Sql Server 2008 ( more info here => Table-Valued Parameters ). I just don't want to pass multiple ids within an nvarchar parameter and then chop its value on the SQL Server side. 回答1: My first, ad hoc, idea was to implement my own IType . public class Sql2008Structured : IType { private static readonly SqlType[] x = new[] { new SqlType(DbType.Object) }; public

How to ALTER the Table Value Parameter

风流意气都作罢 提交于 2019-11-27 01:06:50
问题 I am not getting option like 'ALTER TO' when am right clicking on TVP 回答1: Can't do it. You must drop/recreate. If you have dependencies on the TVP, you must: create new TVP under new name alter dependencies to use (1) drop old TVP recreate (1) under original name alter dependencies to use (4) drop (1) 回答2: I've found a blog post on sqltreeo.com which has a way to automate the process by temporary dropping the dependencies and then re-creating them. I just modified it a bit. 1.You should

How can I insert 10 million records in the shortest time possible?

吃可爱长大的小学妹 提交于 2019-11-26 11:44:41
I have a file (which has 10 million records) like below: line1 line2 line3 line4 ....... ...... 10 million lines So basically I want to insert 10 million records into the database. so I read the file and upload it to SQL Server. C# code System.IO.StreamReader file = new System.IO.StreamReader(@"c:\test.txt"); while((line = file.ReadLine()) != null) { // insertion code goes here //DAL.ExecuteSql("insert into table1 values("+line+")"); } file.Close(); but insertion will take a long time. How can I insert 10 million records in the shortest time possible using C#? Update 1: Bulk INSERT: BULK

Entity Framework Stored Procedure Table Value Parameter

ε祈祈猫儿з 提交于 2019-11-26 10:21:55
I'm trying to call a stored procedure that accepts a table value parameter. I know that this isn't directly supported in Entity Framework yet but from what I understand you can do it using the ExecuteStoreQuery command off of the ObjectContext . I have a generic entity framework repository where I have the following ExecuteStoredProcedure method: public IEnumerable<T> ExecuteStoredProcedure<T>(string procedureName, params object[] parameters) { StringBuilder command = new StringBuilder(); command.Append("EXEC "); command.Append(procedureName); command.Append(" "); // Add a placeholder for each

How can I insert 10 million records in the shortest time possible?

笑着哭i 提交于 2019-11-26 02:34:38
问题 I have a file (which has 10 million records) like below: line1 line2 line3 line4 ....... ...... 10 million lines So basically I want to insert 10 million records into the database. so I read the file and upload it to SQL Server. C# code System.IO.StreamReader file = new System.IO.StreamReader(@\"c:\\test.txt\"); while((line = file.ReadLine()) != null) { // insertion code goes here //DAL.ExecuteSql(\"insert into table1 values(\"+line+\")\"); } file.Close(); but insertion will take a long time.

Entity Framework Stored Procedure Table Value Parameter

别说谁变了你拦得住时间么 提交于 2019-11-26 02:07:37
问题 I\'m trying to call a stored procedure that accepts a table value parameter. I know that this isn\'t directly supported in Entity Framework yet but from what I understand you can do it using the ExecuteStoreQuery command off of the ObjectContext . I have a generic entity framework repository where I have the following ExecuteStoredProcedure method: public IEnumerable<T> ExecuteStoredProcedure<T>(string procedureName, params object[] parameters) { StringBuilder command = new StringBuilder();