更新表中的xml列 [英] Updating a xml column in a table

查看:101
本文介绍了更新表中的xml列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..我对XML知之甚少.我有一个包含数据的表(正在使用SQL Server 2008 R2).现在,我添加了一个新的xml列.我想用我创建的xml文件更新表.谁能帮我这个忙.

Hi.. I have little knowledge on XML. I have a table with data ( am using SQL Server 2008 R2). Now I added a new xml column. I want to update the table with an xml file that I have created. Can anyone help me with this.

Thanks in advace!

推荐答案

我已经使用SQL数据源以编程方式完成了此操作.但是,您必须使用参数化查询.您不能将数据嵌入命令中(无论如何这都是一个坏主意.)使用类型为lSqlDbType.Xml的参数,将参数的Value设置为XML,然后执行插入操作.如果要使用文件进行更新,请认为,可以将文件加载到XDocument对象中并将其设置为参数的值.

我不确定如何使用Sql Manager更新XML列,尽管我怀疑有一种方法可以将文件导入变量并将其作为参数传递.
I''ve done this programmatically, using a SQL data source. You have to use parameterized queries, though; you cannot embed the data in your command (which is a Bad Idea anyway.) Use a parameter of type lSqlDbType.Xml, set the parameter''s Value to your XML, and execute the insert. If you are updating using a file, I think you can load the file into an XDocument object and set that as the parameter''s value.

I am not sure how to update an XML column using Sql Manager, though I suspect there is a way to import a file into a variable and pass that as a parameter.


这篇关于更新表中的xml列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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