Date Processing - T-SQL or SQLCLR ?
"The issue is date processing, which is something that SQL Server seems to be lousy at. There isn't an easy way to find the last day of a given month, or to do things on all the days up to the last day, etc. This is where a short detour to C# can save hours of agony and lots of ugly code."
Oh, I cannot agree with that ! T-SQL is great with dates. The last day of the month ? With a little help from BOL and some tips we get:
SELECT DATEADD(ms, -5, DATEADD(mm, DATEDIFF(m, 0, GETDATE()) + 1, 0))
Enjoy ! Anyway, SQLCLR is a great feature but avoid racing into use of this new technology unless you can state a clear rationale for its use. Transact-SQL set-based access will be faster than paying the transition cost for moving data in/out of the .NET Framework, especially if the set-based query is replaced by cursor-like behavior in the program...
Tuesday, January 3, 2006 12:57 AM