简体   繁体   English

将字符追加到MS SQL 2017中生成的JSON

[英]Append character to a JSON generated in MS SQL 2017

I am able to get a proper output in a JSON format with the following query. 我可以通过以下查询以JSON格式获得正确的输出。 However I need to have a CR+LF character at the end of this string appended. 但是,我需要在此字符串的末尾附加一个CR + LF字符。 So it detects end of line. 因此它检测到行尾。

SELECT top 1 *  FROM customers FOR JSON auto, Root('Customers')

So the output should be something like <JSON>CRLF 因此输出应类似于<JSON>CRLF

I can't test this, as there's no sample data, but would it not simply be..? 我无法测试,因为没有示例数据,但这不是简单的吗?

SELECT (SELECT TOP 1 *
        FROM customers
        FOR JSON auto, Root('Customers')) + CHAR(13) + CHAR(10);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM