|
Posted by Hugo Kornelis on 11/03/06 22:10
On 2 Nov 2006 23:31:55 -0800, boetsid wrote:
>I saw in one of the solutions
>select dt + 1 from #anytable --like ( here dt is a
>datetime field )
>which one is more efficient or robust between
>dateadd(day, 1, dt) -- or only using
>dt + 1
Hi boetsid,
Both are equally robust. The behaviour of + with a datetime argument is
documented in Books Online, so it won't change withour prior warning.
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/4ba8baac-5f07-432c-87c5-d23e7011da55.htm,
example B.
If you want to know which is more efficient, then set up a loop to
repeat this calculation a few million times. Run it twice, using the
different techniques, and compare results. I don't expect that you'll
find any measurable difference, though.
--
Hugo Kornelis, SQL Server MVP
Navigation:
[Reply to this message]
|