A tally table would work well. That is basically what I am building with the sub-select against sys.all_objects. The overhead is there to return a larger data set, but for...
Remember that the day of the week and the name of the week day are included in the function. This way, you can easily exclude these days. These columns are...
Unfortunately, SQL Server 2005 doesn't support ISO Week within DatePart. Some logic could be inserted to allow for this in the function, but the concern would be performance. This function...
tempdb is always going to run under the native compatibility mode. Add a Use tempdb statement before you call the CROSS APPLY and change the context back when done.