This month's discount Comprehensive Database Performance Health Check · Testimonials
SQLAuthority with Pinal Dave
Home
  • Consulting
    • Health Check
  • Free Videos
  • All Articles
    • AI
    • SQL Performance
    • SQL Tips and Tricks
    • Interview Questions and Answers
    • SQL Puzzle
    • SQL Video
    • SQLAuthority News
    • Personal
  • Books
  • Consulting
One borrower whose BranchID is NULL shown three ways: RAW writes three attributes and no BranchID, RAW with ELEMENTS writes three child elements, and ELEMENTS XSINIL writes four with BranchID marked xsi:nil true

FOR XML RAW in SQL Server: Row Names, ROOT, ELEMENTS and NULLs

August 30, 2011
Pinal Dave
SQL Tips and Tricks
SQL NULL, SQL Scripts, SQL Server, SQL XML

FOR XML RAW turns each row of a query into an XML element. This post names the row element, adds a ROOT, switches to ELEMENTS and shows how a NULL value drops out of the output until XSINIL puts it back. Every result comes from SQL Server 2025.

Read More
A grid of four plants with its column names in one red header, beside the same rows as XML where PlantID, PlantName, Light and WaterDays repeat inside every row element

What Is XML in SQL Server: Tags, Attributes and Well-Formed Rules

August 29, 2011
Pinal Dave
SQL Tips and Tricks
SQL Datatype, SQL Scripts, SQL Server, SQL XML

What is XML in SQL Server? It’s plain text where every value carries its own label. This post turns four plant rows into XML with FOR XML RAW, names the parts of a document, and shows the errors SQL Server returns when a rule is broken.

Read More
A detached ceramic lid beside an empty pale cup and a blue cup holding a stone on sage cloth.

FOR XML XSINIL: Emit Missing Fields as Explicit Nil Elements

August 10, 2011
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Scripts, SQL Server, SQL XML

FOR XML XSINIL can represent SQL NULL with an explicit element carrying the xsi:nil attribute. I compare that output with ordinary element omission. An empty string stays a separate input in both versions.

Read More
Save As dialog box.

SQL SERVER – View XML Query Plans in SSMS as Graphical Execution Plan

July 3, 2010
Pinal Dave
SQL Tips and Tricks
Execution Plan, SQL Scripts, SQL Server Management Studio, SQL XML

Want to share a graphical execution plan? Save it as a .sqlplan file and send it. Anyone can open it in SSMS without the tables or indexes behind it.

Read More
SQLAuthority News - Guest Post - SELECT * FROM XML - Jacob Sebastian

SQLAuthority News – Guest Post – SELECT * FROM XML – Jacob Sebastian

June 23, 2010
Pinal Dave
SQL Tips and Tricks
SQL Scripts, SQL Server, SQL XML

Getting NULL when reading a value from XML? Most of the time the XPath expression is wrong. A guest post by Jacob Sebastian on writing it correctly.

Read More
SQL Server query window.

SQL SERVER – Comma Separated Values (CSV) from Table Column – Part 2

December 21, 2009
Pinal Dave
SQL Tips and Tricks
Database, SQL Scripts, SQL String, SQL XML

Comma Separated Values from a table column, part 2: SUBSTRING limits the XML length, so I rewrote the query with STUFF and FOR XML PATH to remove it.

Read More
Gouache painting of a document passing through a schema-shaped stencil

Validate an XML Document in T-SQL With an XSD Schema by Jacob Sebastian

December 2, 2009
Pinal Dave
SQL Tips and Tricks
SQL Scripts, SQL Server, SQL XML

To validate an XML document in SQL Server, store an XSD in a schema collection and type the variable or column with it. Jacob Sebastian’s lesson is kept, and I added tests on SQL Server 2025 that show the error number for each kind of bad document and what DOCUMENT and CONTENT accept.

Read More
Previous 1 2 3 4 5 6 7 Next
  • Books
  • Testimonials
  • Privacy Policy

© 2006 – 2026 All rights reserved. pinal @ SQLAuthority.com