我正在使用SQL Server 2017,我已经能够使用这样的SQL提取脚本数据
rhXMLBlob.value('(/RuntimeScript/RuntimePage/RuntimeVariable[@name=''CALL_CLI''])[1]', 'nvarchar(max)') AS [CLI]
但是我基本上需要了解标头数据的ABORT原因,即result =之后的所有内容(这里是“ ABORT-寻找属性,定向到网站”),我完全无法使用语法。
<RuntimeScript previewmode="no" outcome="ABORT - Looking for property, directed to website" ocu="20" starttime="12/12/2018 11:44:03" endtime="12/12/2018 11:45:47" scriptid="73440180-0149-4BAE-A6BC-08243778C1B1" versionid="48" accountno="106868" operatorid="92" operatorinitials="MBI" operatorname="Mikaela Bigland" callref="3XXXPPCQ" channel="" ddi="01156979471" jobcode="0" billingaccount="" cli="07444019309" activationid="f54090a4-82e2-4c84-b273-e1d0167b725f" work_object_id="" work_lock_id="" work_request_id="" message_guid="1646c00e-c06c-47ed-abc3-f1d615e105e0" instanceid="7f7c26d5-829e-47be-8e3d-02b463a7e623" sequence="1" searchkey="">
<RuntimePage pageid="1">
<RuntimeVariable name="iWorkProcessing" />
<RuntimeVariable name="iResultsProcessing" />
<RuntimeVariable name="QUERY_XML"><NewDataSet>
<Table>
<iDataRowId>2a016220-99a1-44bb-8933-17c143b92eb2</iDataRowId>
<iDataRowId2>6ac4f348-359d-44e1-9f2f-aadeedbbe4b3</iDataRowId2>
</Table>
</NewDataSet></RuntimeVariable>
<RuntimeVariable name="SCRIPT_LAUNCH_REASON">Inbound call</RuntimeVariable>
<RuntimeVariable name="INBOUND_DDI">01156979471</RuntimeVariable>
<RuntimeVariable name="CALL_CLI">07444019309</RuntimeVariable>
<RuntimeVariable name="CALL_DATE">12 December 2018</RuntimeVariable>
<RuntimeVariable name="CALL_TIME">11:44:03</RuntimeVariable>
<RuntimeVariable name="DELIVERY_FLAG" />
<RuntimeVariable name="CB_CONTENT">www.openrent.co.uk</RuntimeVariable>
<RuntimeVariable name="NORMAL_CALL_TYPE_LB">Register interest / non viewing enquiry</RuntimeVariable>
<RuntimeVariable name="LANDLORD_OR_TENANT_LB">Tenant</RuntimeVariable>
<RuntimeVariable name="LANDLORD_ENQUIRY_DETAILS" />
<RuntimeVariable name="LANDLORD_TEL" recipient="no" phonenumber_type="phone">
<RuntimeVariable name="Number">07444019309</RuntimeVariable>
</RuntimeVariable>
<RuntimeVariable name="LANDLINE_INT_LANDLINE_LB" />
<RuntimeVariable name="LANDLORD_EMAIL_ADDRESS" recipient="no" />
<RuntimeVariable name="NO_VIEWING_TEL" recipient="no" phonenumber_type="phone">
<RuntimeVariable name="Number">07444019309</RuntimeVariable>
</RuntimeVariable>
<RuntimeVariable name="NO_VIEWING_ENQUIRY_DETAILS" />
<RuntimeVariable name="INT_LANDLINE_LB" />
<RuntimeVariable name="NO_VIEWING_EMAIL_ADDRESS" recipient="no" />
<RuntimeVariable name="PROPERTY_REF_LB" />
<RuntimeVariable name="REFERENCE_NUMBER" />
<RuntimeVariable name="PROPERTY_LOAD_OUTCOME" />
<RuntimeVariable name="PROPERTY_SEARCH_FAIL_LB" />
<RuntimeVariable name="PROPERTY_SEARCH_FAIL_NEXT_LB" />
<RuntimeVariable name="REF_YES_TEL" recipient="no" phonenumber_type="phone">
<RuntimeVariable name="Number">07444019309</RuntimeVariable>
</RuntimeVariable>
<RuntimeVariable name="MOBILE_YN" />
<RuntimeVariable name="REF_YES_EMAIL_ADDRESS" recipient="no" />
<RuntimeVariable name="REF_NO_TEL" recipient="no" phonenumber_type="phone">
<RuntimeVariable name="Number">07444019309</RuntimeVariable>
</RuntimeVariable>
<RuntimeVariable name="PR_N_MOBILE_YN" />
<RuntimeVariable name="REF_NO_EMAIL_ADDRESS" recipient="no" />
<RuntimeVariable name="CLOSE_2_LB" />
</RuntimePage>
</RuntimeScript>
我尝试了
rhXMLBlob.value('(/RuntimeScript[@outcome])[1]', 'nvarchar(max)') AS [outcome reason]
但返回了:
&l t; Table&g t;
及其下面的所有内容。我跌倒了,好像我接近了,但是不知道正确的语法。有人可以帮忙吗?
答案 0 :(得分:3)
您需要的表达式是:
YourXmlColumn.value('(/RuntimeScript/@outcome)[1]','nvarchar(4000)')
您可以在下面进行测试:
SELECT YourXmlColumn.value('(/RuntimeScript/@outcome)[1]','nvarchar(4000)'), V.YourXMLColumn
FROM (VALUES(CONVERT(xml,' <RuntimeScript previewmode="no" outcome="ABORT - Looking for property, directed to website" ocu="20" starttime="12/12/2018 11:44:03" endtime="12/12/2018 11:45:47" scriptid="73440180-0149-4BAE-A6BC-08243778C1B1" versionid="48" accountno="106868" operatorid="92" operatorinitials="MBI" operatorname="Mikaela Bigland" callref="3XXXPPCQ" channel="" ddi="01156979471" jobcode="0" billingaccount="" cli="07444019309" activationid="f54090a4-82e2-4c84-b273-e1d0167b725f" work_object_id="" work_lock_id="" work_request_id="" message_guid="1646c00e-c06c-47ed-abc3-f1d615e105e0" instanceid="7f7c26d5-829e-47be-8e3d-02b463a7e623" sequence="1" searchkey="">
<RuntimePage pageid="1">
<RuntimeVariable name="iWorkProcessing" />
<RuntimeVariable name="iResultsProcessing" />
<RuntimeVariable name="QUERY_XML"><NewDataSet>
<Table>
<iDataRowId>2a016220-99a1-44bb-8933-17c143b92eb2</iDataRowId>
<iDataRowId2>6ac4f348-359d-44e1-9f2f-aadeedbbe4b3</iDataRowId2>
</Table>
</NewDataSet></RuntimeVariable>
<RuntimeVariable name="SCRIPT_LAUNCH_REASON">Inbound call</RuntimeVariable>
<RuntimeVariable name="INBOUND_DDI">01156979471</RuntimeVariable>
<RuntimeVariable name="CALL_CLI">07444019309</RuntimeVariable>
<RuntimeVariable name="CALL_DATE">12 December 2018</RuntimeVariable>
<RuntimeVariable name="CALL_TIME">11:44:03</RuntimeVariable>
<RuntimeVariable name="DELIVERY_FLAG" />
<RuntimeVariable name="CB_CONTENT">www.openrent.co.uk</RuntimeVariable>
<RuntimeVariable name="NORMAL_CALL_TYPE_LB">Register interest / non viewing enquiry</RuntimeVariable>
<RuntimeVariable name="LANDLORD_OR_TENANT_LB">Tenant</RuntimeVariable>
<RuntimeVariable name="LANDLORD_ENQUIRY_DETAILS" />
<RuntimeVariable name="LANDLORD_TEL" recipient="no" phonenumber_type="phone">
<RuntimeVariable name="Number">07444019309</RuntimeVariable>
</RuntimeVariable>
<RuntimeVariable name="LANDLINE_INT_LANDLINE_LB" />
<RuntimeVariable name="LANDLORD_EMAIL_ADDRESS" recipient="no" />
<RuntimeVariable name="NO_VIEWING_TEL" recipient="no" phonenumber_type="phone">
<RuntimeVariable name="Number">07444019309</RuntimeVariable>
</RuntimeVariable>
<RuntimeVariable name="NO_VIEWING_ENQUIRY_DETAILS" />
<RuntimeVariable name="INT_LANDLINE_LB" />
<RuntimeVariable name="NO_VIEWING_EMAIL_ADDRESS" recipient="no" />
<RuntimeVariable name="PROPERTY_REF_LB" />
<RuntimeVariable name="REFERENCE_NUMBER" />
<RuntimeVariable name="PROPERTY_LOAD_OUTCOME" />
<RuntimeVariable name="PROPERTY_SEARCH_FAIL_LB" />
<RuntimeVariable name="PROPERTY_SEARCH_FAIL_NEXT_LB" />
<RuntimeVariable name="REF_YES_TEL" recipient="no" phonenumber_type="phone">
<RuntimeVariable name="Number">07444019309</RuntimeVariable>
</RuntimeVariable>
<RuntimeVariable name="MOBILE_YN" />
<RuntimeVariable name="REF_YES_EMAIL_ADDRESS" recipient="no" />
<RuntimeVariable name="REF_NO_TEL" recipient="no" phonenumber_type="phone">
<RuntimeVariable name="Number">07444019309</RuntimeVariable>
</RuntimeVariable>
<RuntimeVariable name="PR_N_MOBILE_YN" />
<RuntimeVariable name="REF_NO_EMAIL_ADDRESS" recipient="no" />
<RuntimeVariable name="CLOSE_2_LB" />
</RuntimePage>
</RuntimeScript>'))) V(YourXMLColumn);