【问题标题】:ISJSON in Azure Synapse SQL poolAzure Synapse SQL 池中的 ISJSON
【发布时间】:2022-06-28 02:31:47
【问题描述】:

Azure Synapse SQL 池中的 ISJSON 函数存在问题。

下面的代码sn-ps在SQL Server 2016+中正确执行

--test1
SELECT myJsonField
FROM myTable
WHERE ISJSON(myJsonField) = 1

--test2
SELECT ISJSON('{"a":1}')

但是当我在 Azure Synapse SQL 池上执行相同的代码时,我收到以下错误:

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'AS'.

根据文档,该功能应该在 Synapse 中可用:https://docs.microsoft.com/en-us/sql/t-sql/functions/isjson-transact-sql?view=azure-sqldw-latest

Azure Synapse 版本:

SELECT @@VERSION
--Microsoft Azure SQL Data Warehouse - 10.0.15661.0 Jun 20 2022 23:32:43 Copyright (c) Microsoft Corporation

注意:OPENJSON 仍然可以正常工作

【问题讨论】:

  • “关键字'AS'附近的语法不正确。”该批次中没有AS
  • 我知道。这就是它如此令人困惑的部分原因......

标签: json tsql azure-synapse


【解决方案1】:

我已经在本地环境中尝试了一些示例值,并且它可以正常工作。

select @@version version_name

--ex:1
 declare @json nvarchar(max) = '{"time":"2015-04-29T07:12:20.9100000Z","callingimsi":"466920403025604","switch1":"China","switch2":"Germany"}'
 select @json as json_value
 where ISJSON(@json)=1

 --ex:2
 declare @json1 nvarchar(max) = 'abc'
 select @json1 as json_value1
 where ISJSON(@json1)=1

 --ex:3
 SELECT ISJSON('{"a":1}') as validate_json

【讨论】:

    猜你喜欢
    • 2021-01-18
    • 2021-09-19
    • 2021-08-09
    • 2021-12-25
    • 2021-09-05
    • 2021-01-08
    • 2021-06-06
    • 2022-10-04
    • 2023-02-01
    相关资源
    最近更新 更多