• francesco.mantovani - Thursday, October 11, 2018 1:59 PM

    Good stuff! 
    By the way if I copy/paste your code to SSMS I receive: 
    Msg 319, Level 15, State 1, Line 22
    Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
    Msg 319, Level 15, State 1, Line 23
    Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.

    Which version of SQL Server are you using? If it's prior to SQL Server 2016, then the examples using "OPENJSON(...) WITH (...) will not work since that JSON support was introduced in SQL Server 2016.

    Also, thanks everyone for all the kind words!