TSQL - If..Else statement inside Table-Valued Functions - cant go through

后端 未结 7 1369
情话喂你
情话喂你 2021-02-07 02:51

Before posting I have read few articles about developing USD functions, but have not encountered solutions for my problem... which is as follows:

I have a very simple da

相关标签:
7条回答
  • 2021-02-07 03:53

    According to Itzik Ben-Gan in his book "TSQL Querying" (Itzik Ben-Gan et al, (c) 2015 Microsoft Press, ISBN 978-0-7356-8504-8, P. 215) "...I find inline TVFs to be a great tool, allowing for the encapsulation of the logic and reusability without any performance problems of UDF's..."

    He says also that if you need "...a reusable table expression like a View, but you also need to pass input parameters to the table expression...TSQL provides inline table-valued functions (TVFs). "

    This type of 'IF' ( inline function - a distinct type in sys.objects ) uses the 'RETURNS TABLE' output specifier and seemingly cannot contain BEGIN / END. The syntax and allowances are very restrictive, yet we see good optimization and performance. These factors are indicated by the timings seen by @ryk.

    0 讨论(0)
提交回复
热议问题