Yes, R2ro's solution is fast. And if I change
SET @daysDiff = DATEDIFF(day, @prmLoDate, @prmHiDate)
to
SET @daysDiff = 1 + DATEDIFF(day, @prmLoDate, @prmHiDate)
it calculates the right days too.
I tried with the daterange 20060101 to 20060102 (Jan 1 to Jan 2, 2006) and it only gave me the first date.
I think it is good that we have these after discussions. My idea with the article was to give an idea of how to implement a function that gives a daterange on the fly. Of course having a permanent tally table is faster. And it would be better if the counter arguments given are fully tested.
N 56°04'39.16"
E 12°55'05.25"