xquery
XQuery is a query language for XML. XML is a markup language that provides software and hardware-independent way of storing, transporting, and sharing data. In this case, XML documents are stored in a SQL Server database. XQuery is used to manipulate, find and extract information stored in the XML format. It’s analogous to SQL for databases.
XQuery是XML的查询语言。 XML是一种标记语言,它提供独立于软件和硬件的方式来存储,传输和共享数据。 在这种情况下,XML文档存储在SQL Server数据库中。 XQuery用于处理,查找和提取以XML格式存储的信息。 它类似于数据库SQL。
In this article, we’ll introduce different ways to find and replace XML data using SQL Server XQuery.
在本文中,我们将介绍使用SQL Server XQuery查找和替换XML数据的不同方法。
Previously, a developer would update XML information by replacing the full XML document in the table column where it resided. But in the latest versions of SQL Server, we can use the XML modify() function in XQuery to update the XML data type column. We’ll look at both the old and new ways to query and update the data.
以前,开发人员将通过替换其所在的表列中的完整XML文档来更新XML信息。 但是在最新版本SQL Server中,我们可以在XQuery中使用XML Modify()函数来更新XML数据类型列。 我们将研究查询和更新数据的旧方法和新方法。
Refer to the sample table below, called user_details. It has an XML data type column labeled xml_data, and each row has an XML document containing detailed information. For user_id = 1, the value of the fname key is “Jo.” We will update the same row using different methods.
请参阅下面的示例表,名为user_details。 它有一个标记为xml_data的XML数据类型列,每一行都有一个包含详细信息的XML文档。 对于user_id = 1 , fname键的值为“ Jo”。 我们将使用不同的方法更新同一行。