DateDiff function in SQL Server

March 17, 2009 at 3:13 pm (SQL, Technical, Tips and Tricks) (, )

I frequently used to calculate date difference between two dates. I use to open the calendar and calculate the difference. But now I have found a easier way to calculate the date difference using the SQL DateDiff function

DateDiff returns the number of date and time boundaries crossed between two dates.


DateDiff(datepart, startdate, enddate)

Read the rest of this entry »


Permalink 4 Comments

WITH (NOLOCK) IN SQL Server to improve performance

February 27, 2008 at 8:57 am (SQL, Technical, Tips and Tricks)

I used to see my senior developers use WITH (NOLOCK) when querying in SQL Server and wonder why they use. Now i explored it and found that its useful to improve the performance in executing the query. However there is a disadvantage in using it. The disadvantage is that one may not be sure that they are getting the data which is currently being updated in the Table ie Without lock protection, you cannot be guaranteed that the data isn’t changing during the time that the query is running. I reffered this link and found it prettu useful.

Permalink 12 Comments