這個問題是關於流分析。我想將一個blob導出到SQL中。我知道這個過程,我的問題是我必須使用的查詢。解析對象作爲字符串輸出的流天青分析
{"performanceCounter":[{"available_bytes":{"value":994164736.0},"categoryName":"Memory","instanceName":""}],"internal":{"data":{"id":"459bf840-d259-11e5-a640-1df0b6342362","documentVersion":"1.61"}},"context":{"device":{"type":"PC","network":"Ethernet","screenResolution":{},"locale":"en-US","id":"RD0003FF73B748","roleName":"Sdm.MyGovId.Static.Web","roleInstance":"Sdm.MyGovId.Static.Web_IN_1","oemName":"Microsoft Corporation","deviceName":"Virtual Machine","deviceModel":"Virtual Machine"},"application":{"version":"R2.0_20160205.5"},"location":{"continent":"North America","country":"United States","clientip":"104.41.209.0","province":"Washington","city":"Redmond"},"data":{"isSynthetic":false,"samplingRate":100.0,"eventTime":"2016-02-13T13:53:44.2667669Z"},"user":{"isAuthenticated":false,"anonAcquisitionDate":"0001-01-01T00:00:00Z","authAcquisitionDate":"0001-01-01T00:00:00Z","accountAcquisitionDate":"0001-01-01T00:00:00Z"},"operation":{},"cloud":{},"serverDevice":{},"custom":{"dimensions":[],"metrics":[]},"session":{}}}
{"performanceCounter":[{"percentage_processor_total":{"value":0.},"categoryName":"Processor","instanceName":"_Total"}],"internal":{"data":{"id":"459bf841-d259-11e5-a640-1df0b6342362","documentVersion":"1.61"}},"context":{"device":{"type":"PC","network":"Ethernet","screenResolution":{},"locale":"en-US","id":"RD0003FF73B748","roleName":"Sdm.MyGovId.Static.Web","roleInstance":"Sdm.MyGovId.Static.Web_IN_1","oemName":"Microsoft Corporation","deviceName":"Virtual Machine","deviceModel":"Virtual Machine"},"application":{"version":"R2.0_20160205.5"},"location":{"continent":"North America","country":"United States","clientip":"104.41.209.0","province":"Washington","city":"Redmond"},"data":{"isSynthetic":false,"samplingRate":100.0,"eventTime":"2016-02-13T13:53:44.2668221Z"},"user":{"isAuthenticated":false,"anonAcquisitionDate":"0001-01-01T00:00:00Z","authAcquisitionDate":"0001-01-01T00:00:00Z","accountAcquisitionDate":"0001-01-01T00:00:00Z"},"operation":{},"cloud":{},"serverDevice":{},"custom":{"dimensions":[],"metrics":[]},"session":{}}}
{"performanceCounter":[{"percentage_processor_time":{"value":0.0},"categoryName":"Process","instanceName":"w3wp"}],"internal":{"data":{"id":"459bf842-d259-11e5-a640-1df0b6342362","documentVersion":"1.61"}},"context":{"device":{"type":"PC","network":"Ethernet","screenResolution":{},"locale":"en-US","id":"RD0003FF73B748","roleName":"Sdm.MyGovId.Static.Web","roleInstance":"Sdm.MyGovId.Static.Web_IN_1","oemName":"Microsoft Corporation","deviceName":"Virtual Machine","deviceModel":"Virtual Machine"},"application":{"version":"R2.0_20160205.5"},"location":{"continent":"North America","country":"United States","clientip":"104.41.209.0","province":"Washington","city":"Redmond"},"data":{"isSynthetic":false,"samplingRate":100.0,"eventTime":"2016-02-13T13:53:44.2668342Z"},"user":{"isAuthenticated":false,"anonAcquisitionDate":"0001-01-01T00:00:00Z","authAcquisitionDate":"0001-01-01T00:00:00Z","accountAcquisitionDate":"0001-01-01T00:00:00Z"},"operation":{},"cloud":{},"serverDevice":{},"custom":{"dimensions":[],"metrics":[]},"session":{}}}
那麼你可以看到3個json對象哪些對象在數組performanceCounter中有不同的字段。基本上是每個對象的第一個對象。第一個是available_bytes,第二個是percentage_processor_total,第三個是percentage_processor_time。
因爲我將它導出到一個名爲performaceCounter的sql表中,所以我應該爲每個不同的對象都有一個不同的列,所以我想將它保存到一個字符串中,然後在我的應用程序中解析它。
作爲起點我有這個查詢讀取的輸入(斑點)和寫入輸出(SQL)
Select GetArrayElement(A.performanceCounter,0) as a
INTO
PerformanceCounterOutput
FROM PerformanceCounterInput A
這GetArrayElement取入的PerformanceCounter陣列的索引0,但然後寫入一個不同列中查找每個對象中的每個不同字段。所以我應該有所有不同的櫃檯,併爲每一個列,但我的想法更像是一列呼叫performanceCounterData並保存字符串如
「‘available_bytes’:‘值’:994164736.0},‘類別名稱’:」存儲器」, 「實例名」: 「」」
或該
「{」 percentage_processor_total 「:{」 值 「:0.},」 類別名稱 「:」 處理器」, 「實例名」: 「_總」} 「
或
」{「percentage_processor_ti我 「:」 值 「:0.0},」 類別名稱 「:」 過程 「 」實例名「: 」W3WP「}」
我怎麼能投像一個String數組? 我試圖CAST(GetArrayElement(A.performanceCounter,0)作爲爲nvarchar(MAX)),但我不能。
請一些很好的幫助會得到回報
在這種情況下,我需要事先知道將被導出到blob的所有不同計數器(available_bytes,percentage_processor_time ......) 因爲它是JSon,所以我沒有任何結構決定,可以收到不同的計數器。看看我在下面找到的解決方案,看看我的意思。總之非常感謝您的時間和不同的方法 –
GetRecordProperties()函數非常適合這裏。對不起,沒有注意到你已經在使用它了。到目前爲止,您所寫的查詢是最好的方法。 –