XML data type in SQL Server Yukon

zhaozj2021-02-16  58

XML data type in SQL Server Yukon Author: Suhil Srinivas translation: Zhu two original source: http: //www.c-sharpcorner.com/Longhorn/Yukon/XmlDataTypesInYukon.asp Description This article describes the latest version of SQL Server Yukon Beta1 New data types in. This article is a good starting point for any developers who understand the SQL Server2000 and other databases. Introduction When the SQL Server 2000 is issued, there are many features that support XML and Internet applications. It is worth considering to integrate XML into the database engine. As we have seen, SQL Server 2000's successive version SQL Server Yukon Beta1 has taken advantage of the various tools and methods to integrate XML into the database engine of SQL Server. Here are some of the important features of the SQL Server database and XML integration 1. Add XML data type 2, the database engine supports XQuery support 3, enhanced to SQLXML, enhanced for For XML and OpenXML 5, new increase XML DML (XML Data Modification Language) is used to store XML data as an XML data type. 6, xquery designer. In this article, I am only limited to the XML new data type in SQL Server Yukon Beta1. Now, more and more applications support XML, providing a powerful modification / processing / maintenance XML data is important for a database. We know that in SQL Server 2000, we can save XML documents in the database in the database and extract data in the XML document by analyzing, now Yukon is no longer needed. The new XML data type will be stored in a non-text, which enables developers to query a specific node without having to extract, and then analyze then this XML document. The new XML data type makes it easy to process the XML processing of the database layer in the development work. XML data types can be used as a field, variable, or stored procedure / user-defined function parameters, table functions, and triggers like any other data type. , View, etc. Yukon allows CHEK constraints on the XML field, ensuring the integrity of the data. The XML data type can be defined or is not defined. The defined XML is an XML variable, parameter or field and has an XML architecture registered in the database. In other words, the YUKON supports the architecture. This allows YUKON to automatically check the integrity and consistency of the XML document fragment. Developers use create? Xmlschema to register an XML schema and associate the XML entity to the architecture. An associated XML architecture cannot be removed from SQL Server until these XML entities are bound to other presence architectures. On the other hand, an undefined XML does not have an architecture associated with it. Even if the XML binds to the architecture, it is optional, but it is the preferred way. All defined XML all nodes will be used as a local SQL type (just like char, varchar, etc.) so that the definition XML storage is more compact. From the perspective of performance, use the defined XML is a better choice. The existing function icons Cast and Convert are enhanced to support the transition of XML data types. Enhanced OpenRowSet allows XML to load. Several functions that appear together with the XML data type are used to access and update the data type. Methods for supporting XML data types are: 1, query (): This method is used to get a node from an XML variable. This method returns an XML node or an XML fragment. 2, value (): This method applies XQuery on the XML variable, returns a number of values, which is a local SQL type instead of one ?? XML node.

3. EXIST (): As the name suggests, this method checks if the XML variable contains a specific node, or when getting an empty result set in XQuery, it is judged whether to include other strings. 4. Modify (): This method updates the XML variable using the XMLDML syntax. The following is given the use of XML data type and the above method declare @xml xmldeclare @name varchar (20) declare @age intdeclare @xmlfragment xmldeclare @flag bitset @ xml = '

25

New Castle

Male

'Set @name = @xml :: value (' / student / @ name ',' varchar (20) ') set @age = @Xml :: value (' / student / agent / age ',' int ") set @xmlfragment = @XML :: query ('/ student / city') set @flag = @xml :: exist ('/ student / age') print @name 'is' convert (varchar (5), @ agn) 'Years Old'Print Convert (nvarchar, @ xmlfragment) print @flag The message window in the figure below is the result of the return. The usage of the Convert function is shown in the image: convert the XML data type to nVarchar type. The figure below shows the usage of the Modify method. Summary This article simplicity involves some features of the XML data type, not all features. YUKON's support for XML effectively helps the application's developer builds the Internet software supported by XML. -------------------------- Author's introduction SUHIL? SRINIVAS is an experienced developer who develops all kinds of Microsoft technology. Suhil is a MCP, he is very enthusiastic guidance and helping novice. It has a wealth of experience based on web, wireless networks, and background systems, and he has been consulting a variety of companies, especially Suhil has been engaged in credit card and payment processing. In addition, he is also an eduware? Knowledge systems (eks) understands the situation. As a company, EKS has several products for educational institutions for any size. One of the main products is the School-ERP system, which has completely changed the daily management model of educational institutions. In other products, there are also some medical services for small and medium-sized medical services. The EKS also provides consulting services and provides development services to overseas customers through the Office of Bangalore, India.

转载请注明原文地址:https://www.9cbs.com/read-21103.html

New Post(0)