In the following example, an XML instance is stored in a variable of xml type. The value() method retrieves the ProductID attribute value from the XML. The value is then assigned to an int variable. DECLARE XMLģ year parts and labor extended maintenance is availableĪlthough there is only one ProductID attribute in the XML instance, the static typing rules require you to explicitly specify that the path expression returns a singleton. Therefore, the additional is specified at the end of the path expression. Using the value() method to retrieve a value from an xml type column For more information about static typing, see XQuery and Static Typing. The following query is specified against an xml type column ( CatalogDescription) in the AdventureWorks database. Note the following from the previous query: The query retrieves ProductModelID attribute values from each XML instance stored in the column. The namespace keyword is used to define a namespace prefix. Using the value() and exist() methods to retrieve values from an xml type column Per static typing requirements, is added at the end of the path expression in the value() method to explicitly indicate that the path expression returns a singleton.Ĭ. The following example shows using both the value() method and the exist() method of the xml data type. The value() method is used to retrieve ProductModelID attribute values from the XML. The exist() method in the WHERE clause is used to filter the rows from the table.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |