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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.