[quote]Jeff Moden (12/26/2013)
This will lead to some pretty miserable performance on top of it all... it makes for a 100% non-SARGable query. You could have a thousand index on the columns involved and the absolute best you'll ever get is an INDEX SCAN.
WHERE FORMAT(RegularTable.Date,'MM/yyyy') = FORMAT(##TempMonths.x,'MM/yyyy'))
'RegularTable' is updated once a month with a maximum of 10 new entries. That's 120 new lines a year, in twenty years it will have a total of 2,400 records. I don't think that even then performance will be an issue.
That being said, I agree its probably not the best way, so if you have a suggestion on how I should approach that part of the query, please show me an example.