gpt4 book ai didi

sql - T-SQL ISNULL() 优化

转载 作者:行者123 更新时间:2023-12-02 17:21:24 24 4
gpt4 key购买 nike

我在继承的存储过程中的联接上有这个子句:

WHERE a.is_active = 1
AND b.due_date <= ISNULL(@due_date_limit, b.due_date)

我该如何重写它以删除 ISNULL,因为它会导致严重的性能问题?

最佳答案

在这种情况下,我将有一个 if 语句,检查 @due_date_limit

IF (@due_date_limit IS NULL)
BEGIN
...
WHERE a.is_active = 1 --not required to compare b.due_date <= b.due_date
END
ELSE
BEGIN
...
WHERE a.is_active = 1
AND b.due_date <= @due_date_limit
END

关于sql - T-SQL ISNULL() 优化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1444781/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com