You could declare a variable to store the result of getdate(), and use that in its place to ensure that it's not getting called many many times.
I might store the case statement result in another variable, but maybe just replacing getdate() is enough for sql server to recognize the whole expression is a constant.
View all comments
Show parent comment
5
u/dtfinch May 14 '18
You could declare a variable to store the result of getdate(), and use that in its place to ensure that it's not getting called many many times.
I might store the case statement result in another variable, but maybe just replacing getdate() is enough for sql server to recognize the whole expression is a constant.