如何更新SQL Server中的XML属性值。 [英] How to update XML attribute value in SQL server.

查看:138
本文介绍了如何更新SQL Server中的XML属性值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CREATE TABLE [dbo].[tbl_UIConfig](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[PolicyName] [nvarchar](50) NULL,
	[XmlData] [xml] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]


INSERT INTO [dbo].[tbl_UIConfig] VALUES('Policy1', '<main>
<mainUI>
<AppList>
<AppConfig>
	<AppSettings name="notepad" path="c:\Windows\System32\notepad.exe" />
	<AppDesignSettings appLogoName="notepad_534hjj45j35.png" />
</AppConfig>
<AppConfig>
	<AppSettings name="wordpad" path="C:\Program Files\Windows NT\Accessories\wordpad.exe" />
	<AppDesignSettings appLogoName="wordpad_nmb8mn98b908.png" />
</AppConfig>
<AppConfig>
	<AppSettings name="mspaint" path="c:\Windows\System32\mspaint.exe" />
	<AppDesignSettings appLogoName="mspaint_sdf9sd8f89sf.png" />
</AppConfig>
</AppList>
</mainUI>
</main>')



我有一个包含XML的表列和此XML包含应用程序详细信息。

我想做一个功能,如果用户从图像库中删除图像,那么我想更新这个XML。



我想更新那个此XML中的映像名称为默认值(defaultimg.png)。即如果appLogoName包含用户已删除的相同图像,我想更新每个AppConfig元素的AppDesignSettings元素的appLogoName属性。



效果应该发生在每一行中桌子。它应该从AppList检查每个AppConfig节点。



如果你有任何混淆请评论。



谢谢。



我尝试了什么:



我试过哪里只有第一个匹配记录才能更新。但是我想要更新AppList的每个匹配项以及每个表行XML。


I have a table which contains XML column and this XML contains application details.
I want to do a functionality where if user delete image from Image Gallery then I want update this XML.

I want to update that image name to default one(defaultimg.png) in this XML. i.e. I want to update appLogoName atribute of AppDesignSettings element of every AppConfig element if appLogoName contains the same image which user has deleted.

The effect should be happen in every row of the table. and it should check every AppConfig node from AppList.

Please comment if you have any confusion.

Thanks.

What I have tried:

I have tried where only first matching record get update. But I want to update every matching item of AppList and from each table row XML.

推荐答案

这应该可以让你开始...



使用SQL Server 2008表中的新值更新Xml属性 - 堆栈溢出 [ ^ ]
This should get you started...

Updating Xml attributes with new values in a SQL Server 2008 table - Stack Overflow[^]


这篇关于如何更新SQL Server中的XML属性值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆