我有这样的参数
declare @Phl1_descr varchar(50)
SET @Phl1_descr = 'Greece'
declare @Phl2_descr varchar(50)
SET @Phl2_descr = 'Coffee & Beverages'
我想用上述参数加入两个表(如果它们不为空),所以我尝试在ON
my 的“”关键字中执行以下操作JOIN
ON
(CASE WHEN LEN(@Phl1_descr) > 0 THEN A.Phl1_descr ELSE B.Phl1_descr END) = B.Phl1_descr AND
(CASE WHEN LEN(@Phl2_descr) > 0 THEN A.Phl2_descr ELSE B.Phl2_descr END) = B.Phl2_descr
但是,如果我发送 as 之类的参数之一''
,它就不起作用。有更简单的想法吗?