• I hope it is not considered cheating that I did run SELECT database_id, name FROM sys.databases ORDER BY 1; before answering. I don't thik there is any need for me to know ids of system databases by head.

    Other than that, the question was a bit too simple. Just the AND database_id < 2 was sufficient to determine that there would be one result, and there was only one option with one result, so there was no need at all to evaluate the CASE and POWER expressions.

    Anyway, thanks for the question Henrico! Your first, I believe? Hopefully there will be more in the future!


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/