SQL User Defined Function Within Select

前端 未结 3 806
刺人心
刺人心 2021-01-01 08:37

I have a user defined function in SQL called getBuisnessDays it takes @startdate and @enddate and returns the number of business days between the two dates. How can I call t

相关标签:
3条回答
  • 2021-01-01 08:49

    If it's a table-value function (returns a table set) you simply join it as a Table

    this function generates one column table with all the values from passed comma-separated list

    SELECT * FROM dbo.udf_generate_inlist_to_table('1,2,3,4')
    
    0 讨论(0)
  • 2021-01-01 09:04

    Yes, you can do almost that:

    SELECT dbo.GetBusinessDays(a.opendate,a.closedate) as BusinessDays
    FROM account a
    WHERE...
    
    0 讨论(0)
  • 2021-01-01 09:11

    Use a scalar-valued UDF, not a table-value one, then you can use it in a SELECT as you want.

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