views:

194

answers:

1

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?

+4  A: 

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.

gbn
+1 for "correlate acrosss tables"
TheVillageIdiot
Thanks. May I ask: for the usefuleness or for best speeling mistake today...?
gbn
YES! Of course! :-)
marc_s
(don't ever ask these kind of "OR" questions if you can't handle a plain "yes" as the answer) :-)
marc_s