Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在SQL中从select语句导出到JSON_Sql_Sql Server - Fatal编程技术网

在SQL中从select语句导出到JSON

在SQL中从select语句导出到JSON,sql,sql-server,Sql,Sql Server,我使用Microsoft SQL Server Management Studio v17.2。我知道,要将数据导出到JSON,必须使用以下方法: SELECT * FROM table1 WHERE [conditions] FOR JSON PATH, ROOT('root') 但是,当我在SQL Server Management Studio中使用此代码时,发生了一个错误: “json”附近的语法不正确 请帮助我解决此错误。这与Management Studio无关;您正在使用的SS

我使用Microsoft SQL Server Management Studio v17.2。我知道,要将数据导出到JSON,必须使用以下方法:

SELECT * 
FROM table1
WHERE [conditions]
FOR JSON PATH, ROOT('root')
但是,当我在SQL Server Management Studio中使用此代码时,发生了一个错误:

“json”附近的语法不正确


请帮助我解决此错误。

这与Management Studio无关;您正在使用的SSM版本与此无关。这与运行代码所针对的SQL Server版本有关,它与SSMS版本完全不同


SQL Server 2016中引入了FOR JSON。如果您没有运行2016或更高版本或Azure SQL数据库,则需要升级,或使用其他方法将数据转换为JSON格式。

谢谢。那么,如何在SQL server management 17.2中使用JSON呢?目前还没有一个版本的management Studio允许您对不支持JSON语法的服务器使用JSON语法。ManagementStudio不是一个数据库引擎,它只是一个GUI,允许您向引擎发送命令。接收命令的引擎需要支持您发送的语法。