{"id":26428,"date":"2023-05-31T06:44:00","date_gmt":"2023-05-31T04:44:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=26428"},"modified":"2023-08-07T17:39:30","modified_gmt":"2023-08-07T15:39:30","slug":"xml-data-in-sql-server","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/","title":{"rendered":"How to use XML data type in SQL Server with examples?"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\" id=\"h-practical-t-sql-scripts-examples-to-manage-xml-data-in-sql-server\"><strong><em>Practical T-SQL scripts examples to manage XML data in SQL Server. <\/em><\/strong><\/h4>\n\n\n\n<p>How to use the XML data type in SQL Server tables ? To start, XML stands for eXtensible Markup Language, it is a standard IT format for storing and exchanging data across various heterogenous platforms. T-SQL (Transact-SQL), the SQL extension from Microsoft, provides extensive support for XML data, including the ability to query, modify, and validate XML data.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#1-create-and-fill-the-table-used-in-the-t-sql-xml-scripts\" >1. Create and fill the table used in the T-SQL XML scripts<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#2-query-xml-data-with-sql-server\" >2. Query XML Data with SQL Server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#3-xml-data-modification-in-t-sql\" >3. XML Data Modification in T-SQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#4-script-example-to-query-xml-columns\" >4. Script example to query XML Columns<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#5-modifying-xml-columns\" >5. Modifying XML Columns<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#6-updating-xml-data-in-a-t-sql-table\" >6. Updating XML data in a T-SQL Table<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#7-querying-data-in-a-t-sql-xml-table\" >7. Querying data in a T-SQL XML Table<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-1-create-and-fill-the-table-used-in-the-t-sql-xml-scripts\"><span class=\"ez-toc-section\" id=\"1-create-and-fill-the-table-used-in-the-t-sql-xml-scripts\"><\/span>1. Create and fill the table used in the T-SQL XML scripts<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let&#8217;s consider the following sample table to manage and store products for this tutorial.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CREATE TABLE Products(\n    ProductID int PRIMARY KEY,\n    Name varchar(100),\n    Description varchar(500),\n    Price decimal(10,2),\n    CategoryID int\n);\n<\/pre>\n\n\n\n<p>Now let&#8217;s insert a few sample rows to fill your <code>Products<\/code> table with 8 entries.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">INSERT INTO Products(ProductID, Name, Description, Price, CategoryID)\nVALUES (1, 'Product 1', 'This is a description for product 1', 23.99, 10);\n\nINSERT INTO Products(ProductID, Name, Description, Price, CategoryID)\nVALUES (2, 'Product 2', 'This is a description for product 2', 45.50, 10);\n\nINSERT INTO Products(ProductID, Name, Description, Price, CategoryID)\nVALUES (3, 'Product 3', 'This is a description for product 3', 29.99, 20);\n\nINSERT INTO Products(ProductID, Name, Description, Price, CategoryID)\nVALUES (4, 'Product 4', 'This is a description for product 4', 33.00, 20);\n\nINSERT INTO Products(ProductID, Name, Description, Price, CategoryID)\nVALUES (5, 'Product 5', 'This is a description for product 5', 16.50, 30);\n\nINSERT INTO Products(ProductID, Name, Description, Price, CategoryID)\nVALUES (6, 'Product 6', 'This is a description for product 6', 20.00, 30);\n\nINSERT INTO Products(ProductID, Name, Description, Price, CategoryID)\nVALUES (7, 'Product 7', 'This is a description for product 7', 19.99, 40);\n\nINSERT INTO Products(ProductID, Name, Description, Price, CategoryID)\nVALUES (8, 'Product 8', 'This is a description for product 8', 24.99, 40);\n<\/pre>\n\n\n\n<p>These statements will create 8 products, each with a unique ID and having 5 columns: <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Product ID<\/li>\n\n\n\n<li>name<\/li>\n\n\n\n<li>description<\/li>\n\n\n\n<li>price<\/li>\n\n\n\n<li>and associated category ID.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-2-query-xml-data-with-sql-server\"><span class=\"ez-toc-section\" id=\"2-query-xml-data-with-sql-server\"><\/span>2. Query XML Data with SQL Server<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>T-SQL provides the <code>FOR XML<\/code> clause <strong>to return query results as XML<\/strong>. This can be used in various modes: RAW, AUTO, EXPLICIT, and PATH. For instance, to get all products in XML format:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT ProductID, Name, Description, Price, CategoryID\nFROM Products\nFOR XML AUTO;\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-3-xml-data-modification-in-t-sql\"><span class=\"ez-toc-section\" id=\"3-xml-data-modification-in-t-sql\"><\/span>3. XML Data Modification in T-SQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can store XML data in a column by using the <code>xml<\/code> data type. For instance:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CREATE TABLE ProductDetails(\n    ProductID int PRIMARY KEY,\n    Details xml\n);\n<\/pre>\n\n\n\n<p>To insert XML data in a SQL Server column, use the following script:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">INSERT INTO ProductDetails(ProductID, Details)\nVALUES (1, '&lt;details>&lt;color>Red&lt;\/color>&lt;size>M&lt;\/size>&lt;weight>1.2&lt;\/weight>&lt;\/details>')\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-4-script-example-to-query-xml-columns\"><span class=\"ez-toc-section\" id=\"4-script-example-to-query-xml-columns\"><\/span>4. Script example to query XML Columns<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>XML columns can be queried using the <code>.value<\/code>, <code>.query<\/code>, and <code>.exist<\/code> methods provided by T-SQL. For instance, to get the color of a product:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT ProductID, \n       Details.value('(\/details\/color)[1]', 'varchar(50)') as Color\nFROM ProductDetails\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-5-modifying-xml-columns\"><span class=\"ez-toc-section\" id=\"5-modifying-xml-columns\"><\/span>5. Modifying XML Columns<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>XML data can be modified using the <code>.modify<\/code> method. As an example, to update the color of a product, using the ProductID key, use and adapt a T-SQL script like this one:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">UPDATE ProductDetails\nSET Details.modify('replace value of (\/details\/color\/text())[1] with \"Blue\"')\nWHERE ProductID = 1\n<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"6-updating-xml-data-in-a-t-sql-table\"><\/span>6. Updating XML data in a T-SQL Table<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Consider that we have an XML column in the Products table to store additional details about the products. Let&#8217;s add this column:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ALTER TABLE Products\nADD ProductDetails xml;\n<\/pre>\n\n\n\n<p>We could store product specifications or <a href=\"https:\/\/www.xml.com\/axml\/axml.html\" target=\"_blank\" rel=\"noreferrer noopener\">other details in XML standard format<\/a>. Let&#8217;s say we want to update the XML details for <code>ProductID<\/code> 1:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">UPDATE Products\nSET ProductDetails = '\n&lt;details>\n    &lt;color>Red&lt;\/color>\n    &lt;size>Medium&lt;\/size>\n    &lt;weight>1.2kg&lt;\/weight>\n&lt;\/details>'\nWHERE ProductID = 1;\n<\/pre>\n\n\n\n<p>With this, we can store structured XML data directly in the table and update it as needed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"7-querying-data-in-a-t-sql-xml-table\"><\/span>7. Querying data in a T-SQL XML Table<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now that we have some XML data in our table, we may want to query this data. We can use the <code>.value<\/code> XML method in T-SQL to do this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT ProductID, \n       Name, \n       Price, \n       ProductDetails.value('(\/details\/color)[1]', 'varchar(50)') as Color, \n       ProductDetails.value('(\/details\/size)[1]', 'varchar(50)') as Size, \n       ProductDetails.value('(\/details\/weight)[1]', 'varchar(50)') as Weight\nFROM Products\nWHERE ProductID = 1;\n<\/pre>\n\n\n\n<p>This will return a row with the <code>ProductID<\/code>, <code>Name<\/code>, <code>Price<\/code>, and the values of the <code>color<\/code>, <code>size<\/code>, and <code>weight<\/code> XML nodes. Remember that working with XML data in SQL can be tricky, but it can also <strong><em>provide a lot of flexibility when you need to store structured data<\/em><\/strong> that doesn&#8217;t fit neatly into the SQL table structure. And of course when you need a flexible and changing data structure.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-conclusion-on-xml-data-in-sql-server\">Conclusion on XML data in SQL Server<\/h3>\n\n\n\n<p>That&#8217;s it for how to use XML data type in SQL Server. This short tutorial has introduced the integration and use of XML data type with SQL Server data handling is a powerful feature in T-SQL, making it easier to exchange data between different platforms and systems. Practicing these concepts with more complex examples will help you become proficient in using XML with T-SQL. To go further, let&#8217;s check our other XML tutorial with a <a href=\"https:\/\/expert-only.com\/en\/t-sql\/implicit-conversion-from-xml-to-nvarchar\/\">workaround to avoid the implicit XML conversion error<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-wp-embed is-provider-sql-and-it-tutorials wp-block-embed-sql-and-it-tutorials\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"mTWZ7JNFDq\"><a href=\"https:\/\/expert-only.com\/en\/t-sql\/implicit-conversion-from-xml-to-nvarchar\/\">Implicit conversion from data type XML to NVARCHAR T-SQL error<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Implicit conversion from data type XML to NVARCHAR T-SQL error&#8221; &#8212; SQL and IT Tutorials\" src=\"https:\/\/expert-only.com\/en\/t-sql\/implicit-conversion-from-xml-to-nvarchar\/embed\/#?secret=h20FsWesoC#?secret=mTWZ7JNFDq\" data-secret=\"mTWZ7JNFDq\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Practical T-SQL scripts examples to manage XML data in SQL Server. How to use the XML data type in SQL Server tables ? To start, XML stands for eXtensible Markup Language, it is a standard IT format for storing <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/\" title=\"How to use XML data type in SQL Server with examples?\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":10874,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[454],"tags":[],"class_list":{"0":"post-26428","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-t-sql"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.7 (Yoast SEO v26.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Use XML data type in SQL Server - T-SQL<\/title>\n<meta name=\"description\" content=\"How to use and manipulate XML data type including columns to query, modify, and validate XML schema using SQL Server and T-SQL.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use XML data type in SQL Server with examples?\" \/>\n<meta property=\"og:description\" content=\"How to use and manipulate XML data type including columns to query, modify, and validate XML schema using SQL Server and T-SQL.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL and IT Tutorials\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-31T04:44:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-07T15:39:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-273B124DF7D_1920x1080.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Expert-Only\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@expert_only\" \/>\n<meta name=\"twitter:site\" content=\"@expert_only\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Expert-Only\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"How to use XML data type in SQL Server with examples?\",\"datePublished\":\"2023-05-31T04:44:00+00:00\",\"dateModified\":\"2023-08-07T15:39:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/\"},\"wordCount\":540,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-273B124DF7D_1920x1080.jpg\",\"articleSection\":[\"T-SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/\",\"url\":\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/\",\"name\":\"Use XML data type in SQL Server - T-SQL\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-273B124DF7D_1920x1080.jpg\",\"datePublished\":\"2023-05-31T04:44:00+00:00\",\"dateModified\":\"2023-08-07T15:39:30+00:00\",\"description\":\"How to use and manipulate XML data type including columns to query, modify, and validate XML schema using SQL Server and T-SQL.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-273B124DF7D_1920x1080.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-273B124DF7D_1920x1080.jpg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use XML data type in SQL Server with examples?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/expert-only.com\/en\/#website\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"name\":\"SQL and IT Tutorials\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/expert-only.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/expert-only.com\/en\/#organization\",\"name\":\"Expert-Only\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"width\":381,\"height\":174,\"caption\":\"Expert-Only\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\",\"https:\/\/x.com\/expert_only\",\"https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\",\"name\":\"Expert-Only\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"caption\":\"Expert-Only\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Use XML data type in SQL Server - T-SQL","description":"How to use and manipulate XML data type including columns to query, modify, and validate XML schema using SQL Server and T-SQL.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/","og_locale":"en_US","og_type":"article","og_title":"How to use XML data type in SQL Server with examples?","og_description":"How to use and manipulate XML data type including columns to query, modify, and validate XML schema using SQL Server and T-SQL.","og_url":"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2023-05-31T04:44:00+00:00","article_modified_time":"2023-08-07T15:39:30+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-273B124DF7D_1920x1080.jpg","type":"image\/jpeg"}],"author":"Expert-Only","twitter_card":"summary_large_image","twitter_creator":"@expert_only","twitter_site":"@expert_only","twitter_misc":{"Written by":"Expert-Only","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"How to use XML data type in SQL Server with examples?","datePublished":"2023-05-31T04:44:00+00:00","dateModified":"2023-08-07T15:39:30+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/"},"wordCount":540,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-273B124DF7D_1920x1080.jpg","articleSection":["T-SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/","url":"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/","name":"Use XML data type in SQL Server - T-SQL","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-273B124DF7D_1920x1080.jpg","datePublished":"2023-05-31T04:44:00+00:00","dateModified":"2023-08-07T15:39:30+00:00","description":"How to use and manipulate XML data type including columns to query, modify, and validate XML schema using SQL Server and T-SQL.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-273B124DF7D_1920x1080.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-273B124DF7D_1920x1080.jpg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/t-sql\/xml-data-in-sql-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to use XML data type in SQL Server with examples?"}]},{"@type":"WebSite","@id":"https:\/\/expert-only.com\/en\/#website","url":"https:\/\/expert-only.com\/en\/","name":"SQL and IT Tutorials","description":"","publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/expert-only.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/expert-only.com\/en\/#organization","name":"Expert-Only","url":"https:\/\/expert-only.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","width":381,"height":174,"caption":"Expert-Only"},"image":{"@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ExpertOnlyCom\/","https:\/\/x.com\/expert_only","https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA"]},{"@type":"Person","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef","name":"Expert-Only","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","caption":"Expert-Only"}}]}},"_links":{"self":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/26428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/comments?post=26428"}],"version-history":[{"count":0,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/26428\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/10874"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=26428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=26428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=26428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}