OPENJSON在SQL Server中不起作用? [英] OPENJSON does not work in SQL Server?

查看:1536
本文介绍了OPENJSON在SQL Server中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在SQL Server 2016中使用JSON函数,但是当我尝试执行OPENJSON函数时,出现以下错误:

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

第208条消息,第16级,状态1,第1行
无效的对象名称"openjson".

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

为什么它不起作用?我有SQL Server 2016 RC版本.

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

推荐答案

可以检查数据库的兼容性级别吗? OPENJSON在兼容级别130下可用.您能否尝试执行:

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

此外,如果要在Azure SQL数据库上使用JSON,请注意,即使新数据库也是在120兼容级别下创建的,因此如果要使用OPENJSON,则应更改它. 另外,如果您在Azure SQL数据库中使用它,请运行select @@ version以查看此V12服务器.您应该会看到类似

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 2016年3月25日15:11:30 版权所有(c)Microsoft Corporation

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

如果看到较低版本(例如11.xxx),则可能是在不支持JSON的旧体系结构上建立的数据库.

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

此致

Jovan

这篇关于OPENJSON在SQL Server中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆