Unable to build Visual Studio database solution when using OPENJSON

  • Greetings, all.
    I am working with a database project in Visual Studio.Enterprise 2015 & SQL Server 2016. I constructed some procedures & functions using the new JSON functionality. They work in SQL Server (with compatibility level 130.) However, if I add those code components to my Visual Studio project & try to build the solution, it fails, generating all kinds of syntax errors. Looking online, the only thing I can find is that there may be an as-yet-not-completely-fixed issue with OPENJSON in Visual Studio.
    Has anyone here encountered this issue? Do you have a solution, workaround, etc.?
    Thanks,
    Randy  

    P.S. I did submit this question also in the SSDT forum, but the activity in that forum appears low so I submitted it in this forum as well.

  • wittr - Wednesday, November 1, 2017 9:45 AM

    Greetings, all.
    I am working with a database project in Visual Studio.Enterprise 2015 & SQL Server 2016. I constructed some procedures & functions using the new JSON functionality. They work in SQL Server (with compatibility level 130.) However, if I add those code components to my Visual Studio project & try to build the solution, it fails, generating all kinds of syntax errors. Looking online, the only thing I can find is that there may be an as-yet-not-completely-fixed issue with OPENJSON in Visual Studio.
    Has anyone here encountered this issue? Do you have a solution, workaround, etc.?
    Thanks,
    Randy  

    P.S. I did submit this question also in the SSDT forum, but the activity in that forum appears low so I submitted it in this forum as well.

    I created a new database in SSDT 2015 and added a single proc (stolen from BOL):
    CREATE PROCEDURE dbo.Proc1
    AS
    DECLARE @jsonInfo NVARCHAR(MAX);
    DECLARE @town NVARCHAR(32);

    SET @jsonInfo
      = N'{
      "info":{ 
       "type":1,
       "address":{ 
       "town":"Bristol",
       "county":"Avon",
       "country":"England"
       },
       "tags":["Sport", "Water polo"]
      },
      "type":"Basic"
    }';
    SET @town = JSON_VALUE(@jsonInfo, '$.info.address.town');

    SELECT @town;

    This builds successfully. Can you provide an example of something which fails?
    Can you also confirm that the target platform for the project has been set to SQL Server 2016?


  • Hi,
    Issue has been resolved by a teammate. If you go into the Properties for the database project in Visual Studio, you can set Target Platform to SQL Server 2016 & on a sub-screen you can set the Compatibility Level to 130. That resolved the build issues.

  • wittr - Wednesday, November 1, 2017 12:02 PM

    Hi,
    Issue has been resolved by a teammate. If you go into the Properties for the database project in Visual Studio, you can set Target Platform to SQL Server 2016 & on a sub-screen you can set the Compatibility Level to 130. That resolved the build issues.

    Did you notice my comment which already suggested this? 
    Anyhow, glad it's working now.


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

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