OPENJSON does not work in SQL Server?

你说的曾经没有我的故事 提交于 2019-11-28 23:47:01

问题


I want to use JSON functions in SQL Server 2016, but when I try to execute OPENJSON function, I get the following error:

Msg 208, Level 16, State 1, Line 1
Invalid object name 'openjson'.

Why it does not work? I have SQL Server 2016 RC version.


回答1:


Could you check compatibility level on database? OPENJSON is available under compatibility level 130. Could you try to execute:

ALTER DATABASE database_name SET COMPATIBILITY_LEVEL = 130

Also, if you are using JSON on Azure SQL Database, note that even new databases are created under 120 compatibility level so you should change it if you want to use OPENJSON. Also, if you are using it in Azure SQL Database, run select @@version to see is this V12 server. You should see something like:

Microsoft SQL Azure (RTM) - 12.0.2000.8 Mar 25 2016 15:11:30 Copyright (c) Microsoft Corporation

If you see some lower version (e.g. 11.xxx) you probably have database on old architecture where JSON is not supported.

Regards,

Jovan



来源:https://stackoverflow.com/questions/36470782/openjson-does-not-work-in-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!