且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

where子句中的大小写

更新时间:2023-02-06 08:23:47

尝试一下:
这将为您工作.
Try This:
This will work for you.
FROM FWB_SF_Opportunity B left join FWB_VWSFData A ON A.opportunityid=B.id and ReviewMonth=@ReviewMonth
WHERE A.VCID = (case when @vcid <> '' then @VCID end)

>

祝你好运.



Good Luck.


嘿,尝试下面的查询:-

hey try below query:-

declare @vcid int
set @vcid= ''  --for no filter
set @vcid= 100 -- for filter
select *
FROM FWB_SF_Opportunity B left join FWB_VWSFData A 
ON A.opportunityid=B.id and ReviewMonth=@ReviewMonth
WHERE @vcid =  case @vcid  when '' then @vcid else A.VCID  end


SELECT * FROM FWB_SF_Opportunity B left join FWB_VWSFData A ON A.opportunityid=B.id and ReviewMonth=@ReviewMonth
WHERE A.VCID = ISNULL(@VCID,A.VCID)



试试这个.可能有帮助,我尚未测试.

我有另一个解决方案:-如果您的代码在过程中,则在放入代码之前,可以借助IF ELSE条件检查@VCID是否为空



Try this one. It may help, I have not tested.

I have Another solution:- If your code is inside a procedure then before puting your code you can check whether @VCID is null or not null by the help of IF ELSE condition