The calls to UDFs are very expensive. If UDF is called for each record than it'll slow down query significantly. The first one guaranties that UDF will be called only 2 times. The second case depends on how smart SQL Query optimizer is.
>I've inherited a system with SQL stored procedures and functions. I want to clarify my understanding.
>
>Would this ...
>
>select @startdate = dbo.myfunction(@startdate)
>select @enddate = dbo.myfunction(@enddate)
>
>SELECT * from table where datefield between @startdate and @enddate
>
>be better than this...
>
>SELECT * from table where datefield between dbo.myfunction(@startdate) and dbo.myfunction(@enddate)
--sb--