我正在尝试将XML插入到SQL Server表中,但是我收到错误:
Msg 2205,Level 16,State 1,Line 10
预计XQuery [value()]:“)”。
代码:
DECLARE @XML XML = '<list>
<object Index="0" Type="0" Name="obj1" Level="6" />
<object Index="1" Type="0" Name="obj2" Level="9" />
</list>'
INSERT INTO dbo.testt(test1, test2, test3, test4)
SELECT
test1 = Events.value('@Index','int'),
test2 = Events.value('@Type','varchar'),
test3 =Events.value('@Name','varchar'),
test4 =Events.value('(@Level','int')
FROM
@XML.nodes('/list/object') AS testtt(Events)
谢谢!
答案 0 :(得分:3)
(
之前有@Level
test4 =Events.value('(@Level','int')
应该是:
test4 =Events.value('@Level','int')