2013-07-16 75 views
0

隨着下表......如果我想用別的東西來完全替換xml列的內容,替換(或刪除/插入)將會是什麼樣的......不會有類似的在公共節點,但是我需要的PK我留下完整sql服務器xml替換或刪除

CREATE TABLE T (i int, x xml) 
go 
INSERT INTO T VALUES(1,'<Root> 
<ProductDescription ProductID="1" ProductName="Road Bike"> 
<Features> 
<Warranty>1 year parts and labor</Warranty>enter code here 
<Maintenance>3 year parts and labor extended maintenance is available</Maintenance> 
</Features> 
</ProductDescription> 
/Root>') 

回答

0
update t 
set x='<Root> 
<ProductDescription ProductID="1" ProductName="Road Bike v2"> 
<Features> 
<Warranty>1 year parts and labor</Warranty>enter code here 
<Maintenance>3 year parts and labor extended maintenance is available</Maintenance> 
</Features> 
</ProductDescription> 
/Root>' 
where i=1 
+0

是啊,你不能更新這樣的XML數據類型...你發佈前試試你的答案? – Bayrat