I’ve been giving a few lightening talks on the topic of querying XML in SQL Server recently and this has really forced me to squeeze my blog content down into as small a space as possible. Part of that process was gathering examples that cover the maximum number of concepts in the minimum number of examples.
To make sure all my examples actually worked I gathered them together in another SQL Notebook this was for my own benefit to start with but I quickly realised it also to gives others the chance to run or change the examples themselves, it’s missing the full detail of my other blog posts and the notebooks I copied them into but if all you need is a few quick examples of values, nodes, exist or query methods it’s a great thing to have to hand.
Here’s the link:
A Cheat Sheet For Querying XML In SQL Server
It’s viewable directly in GitHub but best used in Azure Data Studio, preferably connected to an instance of SQL Server so you can run the queries.
Have fun with it and do let me know if there are any key examples you feel are missing.
Querying XML In SQL Server Series
- Part 1 – Introduction
- Part 2 – Simple Paths and Attributes With the Value Method
- Part 3 – Handling Repeating Regions With the Nodes Method
- Part 4 – Filtering With The Exist Method
- Part 5 – Introduction to the Query Method and XQuery
- Part 6 – Sequencing Elements and Finding Positions
- Part 7 – Creating XML