Questions tagged [inline-table-function]

15 questions
4
votes
1 answer

TSQL: avoid MAXRECURSION limit in a inline function

I have this function that given a initial and final date gives the corresponding year/month in that range: CREATE FUNCTION [dbo].[fnYearMonth] ( @Initial Date, @Final Date ) RETURNS TABLE AS RETURN With dateRange(StatDate) as ( select…
2
votes
0 answers

ITVF poor performance vs different parameter vs ad hoc

I have an Inline Table Valued Function and for some reason it runs incredibly slow, to the point where I just have to cancel it. When I run the same exact SQL on an ad hoc basis, and create the parameters by declaring and setting them, it runs in…
2
votes
1 answer

SQL Server 2012 Inline table-valued function returning empty rows

I have a table called TaxLots that was created with these columns: CREATE TABLE Portfolio.TaxLots ( Ticker varchar(22) NOT NULL, SecurityDescription varchar(50) NOT NULL, Class varchar(15) NULL, Ccy varchar(5) NULL, LSPosition char(3) NULL, Date…
2
votes
0 answers

Is there any way to return a table in a User Defined Function without defining it?

I have a stored procedure that returns a result set and that I would like to convert into a user-defined function so that I can call specific fields from it. I know that a UDF can return a table by using: CREATE FUNCTION fn_FunctionName RETURNS…
1
vote
1 answer

IF Else inside Inline Table Valued Functions

Is it Possible to Use If Else Inside inline table valued function. i have a scalar function where i am using If Else Condition but, that query taking too much time to execute , what i want to convert it as a Inline table valued function. please…
Miranda
  • 259
  • 1
  • 8
  • 19
1
vote
1 answer

Inline table valued function without parameters?

Today I was talking to colleagues about the use of inline table valued functions in SQL Server, why I recommend using them and in what scenarios they are useful. It occurred to me that they do not have to have any input parameters but I couldn't…
mheptinstall
  • 2,109
  • 3
  • 24
  • 44
1
vote
1 answer

How can I convert split function to inline table valued udf in SQL server?

Assuming I have this query ( pseudo) : Select T.a, T.b, (select top 1 element from fn_split(c,',') where element=T.element) From largeTable T Where fn_split runs for each row , I would like to use inline table valued udf so ,…
Royi Namir
  • 144,742
  • 138
  • 468
  • 792
1
vote
0 answers

SQL inline table function with table value parameter hangs

I wrote a inline table function which works fine on my machine (SQL 08 R2 on Win 7), but in any other environment (SQL 08 R2 on Win 2003 Server) just hangs, even under the lightest loads. There are no differences between database or server…
Mr. TA
  • 5,230
  • 1
  • 28
  • 35
0
votes
1 answer

If my ITVF's only argument is used solely as part of a WHERE clause, is there any way to skip that clause?

I recently wrote a view for my users CREATE VIEW FOO AS SELECT * FROM EMPLOYEES They used this view to populate an Excel sheet and they were very happy. They later decided that they wanted one Excel sheet per employee grade, but also wanted to keep…
J. Mini
  • 1,868
  • 1
  • 9
  • 38
0
votes
1 answer

SQL inline function with array input with 2 columns

I have an inline function with an array input (dbo.Invoicenrs_table) like below, how can I extend this function to have a parameter more in the array input (I have extended the user defined table with an extra column) and the extra parameter must…
NoNa1961
  • 3
  • 2
0
votes
2 answers

Inline-table valued function execute as 'user'

Is it possible to execute inline-table valued function as some user? e.g. CREATE FUNCTION fun() WITH EXECUTE AS owner RETURN( ... )
Dana
  • 107
  • 9
0
votes
2 answers

Inline Function, Column names in each view or function must be unique

I have join the two table and now i want to save that statement in function so that I can use that again and again. I tried to create the function as follow:- create function fn_electricalsem1and2() returns table as return ( Select * …
Awesome
  • 560
  • 2
  • 7
  • 18
0
votes
1 answer

Performance impact of Inline Table Value Function in SQL

I have a stored procedure using an inline Table Value Function (ITVF) in a data warehouse system. If I copy the code of ITVF to the procedure itself then it makes a lot of performance improvement (from 50 seconds to 9 seconds). I was under…
developer
  • 1,401
  • 4
  • 28
  • 73
0
votes
1 answer

How to pass user-defined table type to inline function

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…
Artem
  • 1,773
  • 12
  • 30
0
votes
1 answer

SQL Server failing recursive call between functions at production server

I have one scalar-valued function, func-A and inline table-valued function, func-B. func-A calls func-B and func-B again calls func-A recursively. but the recursion level will never be too deep. It must always be 2 levels. For example, func-A calls…