.value() always requires a positional reference to identify the node you want.
declare @d xml
set @d = '<doc><id>1</id><id>2</id></doc>'
select Data.Col.value('.[1]', 'Int')
from @d.nodes('/doc/id')
as Data(Col)
Вопрос
What is the correct way to pull the list of IDs from this document as ints?
declare @d xml
set @d = '<doc><id>1</id><id>2</id></doc>'
select Data.Col.value('/text()', 'Int')
from @d.nodes('/doc/id')
as Data(Col)
Using the method above I get a error XQuery [value()]: 'value()' requires a singleton (or empty sequence), found operand of type 'xdt:untypedAtomic *'
Решение
.value() always requires a positional reference to identify the node you want.
declare @d xml
set @d = '<doc><id>1</id><id>2</id></doc>'
select Data.Col.value('.[1]', 'Int')
from @d.nodes('/doc/id')
as Data(Col)