今天雲次那個資料出錯, 一看,靠,原來的指令碼Bat改稱cmd了。只能修改資料了。
原來的資料:
<VStormCliCreator> <MachineName>B1-Site</MachineName> <NIC>TrunkNetworkSwitch</NIC> <Host>MSD-1531346.fareast.corp.microsoft.com</Host> <Memory>4096</Memory> <Password>User@123</Password> <VLanID>979</VLanID> <PostScripts> <PostScript>\\172.23.93.230\scratch$\v-XXX\Run.bat</PostScript> </PostScripts> <ImageName>97-SP2</ImageName> <OSID>97</OSID></VStormCliCreator>
修改命令:
update dbo.MachineConfigs set CreatorConfig.modify('replace value of
(/VStormCliCreator/PostScripts/PostScript/text())[1] with ("\\172.23.93.230\scratch$\v-XXX\Run.cmd")')
where ID = '49E6303D-577D-43C8-BB57-0533FC19BBEC' select * from dbo.MachineConfigs where ID = '49E6303D-577D-43C8-BB57-0533FC19BBEC'
該後的資料:
<VStormCliCreator> <MachineName>B1-Site</MachineName> <NIC>TrunkNetworkSwitch</NIC> <Host>MSD-1531346.fareast.corp.microsoft.com</Host> <Memory>4096</Memory> <Password>User@123</Password> <VLanID>979</VLanID> <PostScripts> <PostScript>\\172.23.93.230\scratch$\v-XXX\Run.cmd</PostScript> </PostScripts> <ImageName>97-SP2</ImageName> <OSID>97</OSID></VStormCliCreator>
著重感謝 郭勇成的《如何對SQL Server中的XML資料進行insert Update delete》 http://blog.csdn.net/tjvictor/archive/2009/07/21/4368496.aspx
modify方法
該方法可以對 XML資料進行更新。通過XQuery中添加的insert、delete和update關鍵字提供了對XML DML的支援,使用 insert、delete和update關鍵字可以分別插入、刪除和更新一個或多個節點。例如,在查詢時段中輸入以下代碼:
UPDATE books SET xmlCol.modify( 'insert <section num="1"> <content>Background</content> </section> after (/book/title)[1]') where id = 1
在該段代碼的第1行使用UPDATE語句修改books表中xmlCol類型的欄位,在第2~7行使用insert
代碼 1 <book type="computer" publicationdate="2008" ISBN="0-7356-1588-2">
2 <title>c#</title>
3 <author>
4 <first-name>sheng</first-name>
5 <last-name>bin</last-name>
6 </author>
7 <author>
8 <first-name>gengxin</first-name>
9 <last-name>sun</last-name>
10 </author>
11 <price>35.99</price>
12 </book>
執行此段代碼後,在id列值為1的記錄的xmlCol列中添加元素section,此元素將添加在title元素的下面。更改後的xmlCol列的內容將如下所示。
代碼 1 <book type="computer" publicationdate="2008" ISBN="0-7356-1588-2">
2 <title>c#</title>
3 <section num="1">
4 <content>Background</content>
5 </section>
6 <author>
7 <first-name>sheng</first-name>
8 <last-name>bin</last-name>
9 </author>
10 <author>
11 <first-name>gengxin</first-name>
12 <last-name>sun</last-name>
13 </author>
14 <price>35.99</price>
15 </book>