table-valued-parameters

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

回眸只為那壹抹淺笑 提交于 2020-01-26 21:50:29
问题 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

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

对着背影说爱祢 提交于 2020-01-26 21:50:02
问题 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

Table valued Parameter Equivalent in Postgresql

天涯浪子 提交于 2020-01-23 06:35:00
问题 In postgresql- what is the equivalent of stored procedure with table valued paramater(MSSQL)? 回答1: @HamidKhan -Is your development language Java or C #? CREATE TABLE public.employee ( emp_id INTEGER NOT NULL, emp_nm VARCHAR(40), first_in_time TIMESTAMP WITH TIME ZONE DEFAULT clock_timestamp(), last_chg_time TIMESTAMP WITH TIME ZONE DEFAULT clock_timestamp(), CONSTRAINT employee_pkey PRIMARY KEY(emp_id) ) WITH (oids = false); CREATE TYPE public.employee_udt AS ( emp_id INTEGER, emp_nm VARCHAR

Table valued Parameter Equivalent in Postgresql

[亡魂溺海] 提交于 2020-01-23 06:34:06
问题 In postgresql- what is the equivalent of stored procedure with table valued paramater(MSSQL)? 回答1: @HamidKhan -Is your development language Java or C #? CREATE TABLE public.employee ( emp_id INTEGER NOT NULL, emp_nm VARCHAR(40), first_in_time TIMESTAMP WITH TIME ZONE DEFAULT clock_timestamp(), last_chg_time TIMESTAMP WITH TIME ZONE DEFAULT clock_timestamp(), CONSTRAINT employee_pkey PRIMARY KEY(emp_id) ) WITH (oids = false); CREATE TYPE public.employee_udt AS ( emp_id INTEGER, emp_nm VARCHAR

Table Valued Parameters with Estimated Number of Rows 1

依然范特西╮ 提交于 2020-01-15 05:35:25
问题 I have been searching the internet for hours trying to figure out how to improve the performance of my query using table-valued parameters (TVP). After hours of searching, I finally determined what I believe is the root of the problem. Upon examining the Estimated Execution plan of my query, I discovered that the estimated number of rows for my query is 1 anytime I use a TVP. If I exchange the TVP for a query that selects the data I am interested in, then the estimated number of rows is much

How to pass user-defined table type to inline function

谁说胖子不能爱 提交于 2020-01-07 04:36:10
问题 I have some complex function that I want to use in number of queries. It gets some list of values and return aggregate value. For example (I simplify it, it is more complex in deed): CREATE FUNCTION Mean(@N Numbers READONLY) RETURNS TABLE AS RETURN ( SELECT mean = SUM(n.value) / COUNT(*) FROM @N n ) and I want to use it in query: SELECT d.DepartmentName, MeanRate = m.mean FROM Departments d CROSS APPLY Mean( ( SELECT value = e.Rate FROM Employees e WHERE e.DepatmentId = d.DepatmentId ) ) m

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

泄露秘密 提交于 2020-01-02 04:27:09
问题 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

CLR Table-valued function with array argument

坚强是说给别人听的谎言 提交于 2019-12-30 06:11:09
问题 I have a SQL CLR function like this one: public partial class UserDefinedFunctions { [Microsoft.SqlServer.Server.SqlFunction(TableDefinition = "number int", FillRowMethodName = "FillRow")] public static IEnumerable MyClrFunction(object obj) { // read obj array input and then var result = new ArrayList(); result.Add((SqlInt32)1); result.Add((SqlInt32)2); result.Add((SqlInt32)3); return result; } public static void FillRow(object obj, out SqlInt32 number) { number = (SqlInt32)obj; } } I would

create an INDEX for a TVP in SQL 2008

依然范特西╮ 提交于 2019-12-24 05:44:33
问题 Can we create an Index for TVP's(Table valued Parameters) in SQL Server 2008. please can any one give the syntax. Thanks In advance.. Vinay K 回答1: You can have primary key and unique constraints , which will automatically have indexes backing them, but you're unable to declare any indexes explicitly for table types If you think your query could benefit from further indexes, pretty well you'll have to copy the rows from your TVP into a temporary table (not table variable), on which you can

How can I get NHibernate to make a multicolumn table-valued parameter?

徘徊边缘 提交于 2019-12-23 05:27:50
问题 I'd like to pass a two-column table-valued parameter (TVP) to an ISQLQuery : var sql = "INSERT INTO MovieRatings (PersonID, MovieID, Score) " + "SELECT :personID, o.movieID, o.score " + "FROM :scoreObject o"; var query = session.CreateSQLQuery(sql); query.SetInt32("personID", fred.ID); query.SetParameterList("scoreObject", fredsRatings.Select(r => new { movieID = r.Movie.ID, score = r.Score }).ToArray() /*, Optional IType hint here */); query.ExecuteUpdate(); When I do this (or try to hint