I have heard that DateTime.Now
is very expensive call (from here)
Is GETDATE()
in SQL 2005/2008 expensive? Have I to cache it into a variable if my stored procedure uses it a number of times?
I have heard that DateTime.Now
is very expensive call (from here)
Is GETDATE()
in SQL 2005/2008 expensive? Have I to cache it into a variable if my stored procedure uses it a number of times?
It's not expensive: it comes straight from the OS.
I'd cache it anyway. It will most likely be different for separate calls if you have multiple statements. Say you have multiple inserts, surely you'd want the value to correlate acrosss tables?
If it's use in a SELECT, say, for output then it's only evaluated once usually.