JSON in Microsoft SQL Server: A Comprehensive Guide

  • Comments posted to this topic are about the item JSON in Microsoft SQL Server: A Comprehensive Guide

    Ankush Rastogi

    "Turning data into insights, one query at a time."

      [*] Database Enthusiast
      [*] SQL Server Specialist
      [*] Performance Tuning Expert

    LinkedIn | GitHub

    Got a SQL question? Feel free to ask!SELECT 'Have a great day!' AS Greeting;
  • This is a good round-up of what is possible with JSON and SQL Server. Well done on putting it together.

    My one non-JSON comment would be regarding the following:

    Always implement proper error handling when working with JSON data:

    While this is, of course, sound advice, it is followed by a code fragment where the CATCH block contains a SELECT of the errors occurring. Selecting errors in a CATCH block is not good practice, instead, use should be made of RAISERROR or THROW to make sure any errors do not get missed.

     

     


  • Thank you, Phil, I really appreciate the feedback.

    You are absolutely right. Simply selecting the error information inside the CATCH block is not ideal for production scenarios, as it does not rethrow the exception to the caller.

    Using THROW to propagate the original error is the better practice, especially in modern SQL Server versions. I will update the example to reflect that.

    Thanks again for pointing that out.

    Ankush Rastogi

    "Turning data into insights, one query at a time."

      [*] Database Enthusiast
      [*] SQL Server Specialist
      [*] Performance Tuning Expert

    LinkedIn | GitHub

    Got a SQL question? Feel free to ask!SELECT 'Have a great day!' AS Greeting;

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply