我有一個資料庫,其中有一列長字串,我正在尋找一種方法來提取它的某一部分。
這是一個示例:
{
"vendorId": 53,
"externalRef": "38828059 $567.82",
"lines": [{
"amount": 0,
"lineType": "PURCHASE",
"lineItemType": "INVENTORY",
"inventory": {
"cost": 0,
"quantity": 1,
"row": "6",
"seatType": "CONSECUTIVE",
"section": "102",
"notes": "http://testurl/0F005B52CE7F5892 38828059 $567.82 ,special",
"splitType": "ANY",
"stockType": "ELECTRONIC",
"listPrice": 0,
"publicNotes": " https://brokers.123.com/wholesale/event/146489908 https://www.123.com/buy-event/4897564 ",
"eventId": 3757669,
"eventMapping": {
"eventDate": "",
"eventName": "Brandi Carlile: Beyond These Silent Days Tour",
"venueName": "Gorge Amphitheatre"
},
"tickets": [{
"seatNumber": 1527
}]
}
}]
}
我想要提取的只是 http://testurl/0F005B52CE7F5892
有人能夠幫助我使用語法如何呼叫我的查詢,它將創建一個新的臨時列,并為我提供此列中每一行的提取值嗎?
我使用 SQL Server 2008,所以一些較新的功能對我不起作用。
uj5u.com熱心網友回復:
將您的 Sql Server 升級到受支持的版本。
但在那之前,我們對那些敢于面對只用舊的字串函式處理 Json 的恐懼的人表示同情。
select
[notes_url] =
CASE
WHEN [json_column] LIKE '%"notes": "http%'
THEN substring([json_column],
patindex('%"notes": "http%', [json_column]) 10,
charindex(' ', [json_column] ,
patindex('%"notes": "http%', [json_column]) 15)
- patindex('%"notes": "http%', [json_column])-10)
END
from [YourTable];
db<>在這里擺弄
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/375594.html
