如何将 xml 中的值提取到 sql 变量中?
How to extract value from xml into sql variable?
如何从 xml 下方获取一些变量的名称值?
<proc
name="DB_NAME.dbo.up_SP"
thread_allowed="0"
operation_id="12"
queueCreatedDate="2015-01-12T07:14:00.640"
referenceStub="02216CCE-FA4A-4C27-B130-A835F514E22D"
callback-sql="UPDATE dbo.SOME_TABLE SET is_running = 0, last_modified_by = 'up_AsyncMessage', last_modified_date = getdate() WHERE async_job_stub = '022000CE-F00-0000-B000-030000022D'"
/>
DECLARE @myxml XML
SET @myxml = '<proc name="DB_NAME.dbo.up_SP" thread_allowed="0" operation_id="12" queueCreatedDate="2015-01-12T07:14:00.640" referenceStub="02216CCE-FA4A-4C27-B130-A835F514E22D" callback-sql="UPDATE dbo.SOME_TABLE SET is_running = 0, last_modified_by = ''up_AsyncMessage'', last_modified_date = getdate() WHERE async_job_stub = ''022000CE-F00-0000-B000-030000022D''"/>'
SELECT xmlData.A.value('@name', 'VARCHAR(100)') AS DB_Name
FROM @myxml.nodes('proc') xmlData(a)
如何从 xml 下方获取一些变量的名称值?
<proc
name="DB_NAME.dbo.up_SP"
thread_allowed="0"
operation_id="12"
queueCreatedDate="2015-01-12T07:14:00.640"
referenceStub="02216CCE-FA4A-4C27-B130-A835F514E22D"
callback-sql="UPDATE dbo.SOME_TABLE SET is_running = 0, last_modified_by = 'up_AsyncMessage', last_modified_date = getdate() WHERE async_job_stub = '022000CE-F00-0000-B000-030000022D'"
/>
DECLARE @myxml XML
SET @myxml = '<proc name="DB_NAME.dbo.up_SP" thread_allowed="0" operation_id="12" queueCreatedDate="2015-01-12T07:14:00.640" referenceStub="02216CCE-FA4A-4C27-B130-A835F514E22D" callback-sql="UPDATE dbo.SOME_TABLE SET is_running = 0, last_modified_by = ''up_AsyncMessage'', last_modified_date = getdate() WHERE async_job_stub = ''022000CE-F00-0000-B000-030000022D''"/>'
SELECT xmlData.A.value('@name', 'VARCHAR(100)') AS DB_Name
FROM @myxml.nodes('proc') xmlData(a)