• Nice question. I was a bit distracted by the select 1 from #table statement, but opted to choose for the error anyway.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP