Hi,
I wanted to insert the following node in the sql table column. I got following error

Msg 2226, Level 16, State 1, Line 10
XQuery [#tmpAbc.x.modify()]: The target of 'insert' must be a single node, found 'element(Items,xdt:untyped) *'


Create Table #tmpAbc ( x xml)
go
insert into #tmpAbc values('
<ScreenState xmlns="shared" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Items>
<ScreenStateItem>
<Key>Tab</Key>
<Value>0</Value>
</ScreenStateItem>
<ScreenStateItem>
<Key>AllPortfolio</Key>
<Value>True</Value>
</ScreenStateItem>
</Items>
</ScreenState>')
go
select * from #tmpAbc
go

declare @allNode xml
set @allNode='<ScreenStateItem>
<Key>AllPortfolio</Key>
<Value>True</Value>
</ScreenStateItem>'

update #tmpAbc
set x.modify( 'insert sql:variable("@allNode")
before (/ScreenState/Items[1])
')



go
select * from #tmpAbc
go

drop table #tmpAbc