January 28, 2021 at 12:35 am
While trying, in SQL 2016 (13.0.5850.14), to see if CHOOSE allowed an inline query to provide the index value, I tried this:
SELECT CHOOSE((SELECT 1), 'A', 'B', 'C') --<<-- WARNING! Generates a level 20 error (at least on my system)
Of course this worked:
SELECT CHOOSE(1, 'A', 'B', 'C") --<<-- works just fine, of course
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 28, 2021 at 1:39 pm
No errors with SQL 2017 (14.0.3015.40)
____________________________________________________
Deja View - The strange feeling that somewhere, sometime you've optimised this query before
How to get the best help on a forum
http://www.sqlservercentral.com/articles/Best+Practices/61537January 28, 2021 at 8:07 pm
Confirmed error in 2016 Enterprise and Developer Editions with latest CU.
Msg 596, Level 21, State 1, Line 0
Cannot continue the execution because the session is in the kill state.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
Confirmed that 2017 Developer Edition with latest CU works as expected.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply