I have the xml structure below. I am trying to create a temp table by using return result but I couldnt do it.
declare @xml xml
set @xml = '
<Root>
<ValueHolder>
<Value>3.00</Value>
<IsNoteDirty>false</IsNoteDirty>
<Timestamp>
<StampType>Month</StampType>
<Stamp>3</Stamp>
<Year>2007</Year>
</Timestamp>
</ValueHolder>
<ValueHolder>
<Value>23.00</Value>
<IsNoteDirty>false</IsNoteDirty>
<Timestamp>
<StampType>Month</StampType>
<Stamp>3</Stamp>
<Year>2007</Year>
</Timestamp>
</ValueHolder>
</Root>'
select Tab.Col.value('(Value)[1]','MONEY')
from @xml.nodes('/Root/ValueHolder') Tab(Col)
This code works perfect. What I am trying to do is, putting this result to a temp table. I tried this one but it doesnt work
select * into #TempTable
from (select Tab.Col.value('(Value)[1]','MONEY')
from @xml.nodes('/Root/ValueHolder') Tab(Col))
The error message is
Msg 102, Level 15, State 1, Line 26 Incorrect syntax near ‘)’.
Try something like this instead:
Works just fine if I do it this way.