I am using SQL Server 2008 and want to convert table data into json format. Can I convert it directly through firing query?
我正在使用SQL Server 2008,希望将表数据转换为json格式。我能直接通过发射查询转换它吗?
2 个解决方案
#1
1
Built in support for formatting query results is added in SQL Server 2016 and it will be available in Azure Database. In older versions you would need to use CLR or some heavy TSQL like https://www.simple-talk.com/sql/t-sql-programming/producing-json-documents-from-sql-server-queries-via-tsql/
在SQL Server 2016中添加了对格式化查询结果的支持,并且在Azure数据库中也可以使用。在旧版本中,您需要使用CLR或一些繁重的TSQL,如https://www.simple-web-talk.com/sql/t -sql- sql-程序-生成-json-文档-从-sql-服务器-查询- viaa -tsql/
#2
2
I have created a stored procedure that can take your table and output JSON. You can find it at https://github.com/ahliana/SQLTableOrViewToJSON.
我创建了一个存储过程,可以获取您的表并输出JSON。您可以在https://github.com/ahliana/SQLTableOrViewToJSON找到它。
Once you run the stored procedure, you can output your table by making a call like the following: EXEC SQLTableOrViewToJSON 'MyTable', 'C:\WhereIStowMyJSON\'
运行存储过程后,可以通过以下调用输出表:EXEC SQLTableOrViewToJSON 'MyTable', 'C:\ where eistowmyjson ' \'
#1
1
Built in support for formatting query results is added in SQL Server 2016 and it will be available in Azure Database. In older versions you would need to use CLR or some heavy TSQL like https://www.simple-talk.com/sql/t-sql-programming/producing-json-documents-from-sql-server-queries-via-tsql/
在SQL Server 2016中添加了对格式化查询结果的支持,并且在Azure数据库中也可以使用。在旧版本中,您需要使用CLR或一些繁重的TSQL,如https://www.simple-web-talk.com/sql/t -sql- sql-程序-生成-json-文档-从-sql-服务器-查询- viaa -tsql/
#2
2
I have created a stored procedure that can take your table and output JSON. You can find it at https://github.com/ahliana/SQLTableOrViewToJSON.
我创建了一个存储过程,可以获取您的表并输出JSON。您可以在https://github.com/ahliana/SQLTableOrViewToJSON找到它。
Once you run the stored procedure, you can output your table by making a call like the following: EXEC SQLTableOrViewToJSON 'MyTable', 'C:\WhereIStowMyJSON\'
运行存储过程后,可以通过以下调用输出表:EXEC SQLTableOrViewToJSON 'MyTable', 'C:\ where eistowmyjson ' \'