我只需要你的幫助。 我正在尋找解決方案,但沒有任何工程。SQL XML選擇多個屬性
我必須從存儲在我的表的一列中的xml文件中選擇多個屬性。
這是文件:
<ManagerConfig>
<AccountList>
<Account accountID=「1「 friendlyName=「Testname1「> Test </Account>
<Account accountID=「2「 friendlyName=「Testname2「> Test </Account>
<Account accountID=「3「 friendlyName=「Testname3「> Test </Account>
<Account accountID=「4「 friendlyName=「Testname4「> Test </Account>
</AccountList
</ManagerConfig>
對於使用下面的語句這I'm:
set @accountID = @xmlxx.value('(/ManagerConfig/AccountList/Account/@accountId)[1]', 'varchar(max)')
set @friendlyName = @xmlxx.value('(/ManagerConfig/AccountList/Account/@friendlyName)[1]', 'varchar(max)')
結果是:
accountID friendlyname
1 Testname1
當IM改變從價值[1]至[2]即時獲取第二個屬性。所以這沒問題。但我需要所有這些屬性並將它們導出到另一個臨時表中。 我想我可以用可變[@i]替換值:
set @accountID = @xmlxx.value('(/(ManagerConfig/AccountList/Account/@accountId)'[@i]'', 'varchar(max)')
但有一個語法錯誤:
An insufficient number of arguments were supplied for the procedure or function value.
我希望你能幫助我找到一個解決辦法..
格爾茨 丹尼斯
但是你試圖將* result *賦值爲一個標量變量。您如何期望將4個值填入可包含1個值的變量? –