11

So I recently installed SQL Server 2016 CTP3 mainly for the JSON output feature. I am trying to using it in my SQL Query exactly like how its shown in the link below on MSDN. The keyword JSON does not turn blue and gives error "Incorrect syntax near 'JSON'"

https://msdn.microsoft.com/en-us/library/dn921882%28v=sql.130%29.aspx?f=255&MSPPError=-2147217396

What could be wrong?

EDIT: I'm testing it with AdventureWorks DB for SQL Server 2016. The query is

SELECT * FROM Person.Contact FOR JSON AUTO
10
  • 1
    What is the database compatibility level Commented Jan 30, 2016 at 17:44
  • 3
    Run this query ALTER DATABASE database_name SET COMPATIBILITY_LEVEL = 130. Source : MSDN Commented Jan 30, 2016 at 17:51
  • 1
    Did you check the link i added in previous comment. It should work if you are using Sql Server 2016 Commented Jan 30, 2016 at 18:01
  • 3
    What does select @@version show you? Commented Jan 30, 2016 at 18:01
  • 2
    So you are using SQL Server 2016 management studio but connecting to a 2014 instance. Commented Jan 30, 2016 at 19:10

1 Answer 1

23
  1. Check if compatibility level is set to SQL Server 2016 or 130
  2. Connect to a 2016 instance instead of the older one. (Migrate DB)

Thanks to Martin and VR46

Sign up to request clarification or add additional context in comments.

4 Comments

Mark it as answer :)
Done. Thanks again. :)
what if database says: Valid values of the database compatibility level are 100, 110, or 120.
version: Microsoft SQL Server 2014 and I'm using SQL Server 2016 Management Studio

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.