OUTER APPLY有条件地将值传递给函数

时间:2010-11-10 19:14:27

标签: sql sql-server

有没有办法有条件地将值传入此语句?

    OUTER APPLY [dbo].[udf_GETVMSFleet](o.ClientNum, ou.[UnitNum]) AS orgLevels

我需要的是说ou.UnitNum =''然后ou。[TailerNum]

1 个答案:

答案 0 :(得分:3)

函数调用允许参数表达式(与存储过程不同)

OUTER APPLY [dbo].[udf_GETVMSFleet](o.ClientNum,
  CASE WHEN ou.[UnitNum] = '' THEN ou.[TailerNum] ELSE ou.[UnitNum] END
) AS orgLevels