Find Customers Who Bought "A" and "B" But Not "C" (SQL Spackle)
By Jeff Moden,http://www.sqlservercentral.com/articles/T-SQL/88244/
By Stan Kulp, 2012/03/21
http://www.sqlservercentral.com/articles/XML/87637/
By Arshad Ali
http://www.databasejournal.com/features/mssql/creating-map-report-in-ssrs-sql-server-2008-r2.html

--Declare variables and populate with example data
DECLARE @Cols VARCHAR(MAX)
DECLARE @Xml AS XML = CAST('
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer''s Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications with XML.</description>
</book>' AS XML)
DECLARE @SQL NVARCHAR(MAX)
--Get a list of the columns from the shreded xml document using XMLTable
SELECT @Cols = ISNULL(@Cols, '') + QUOTENAME(XPath) + ','
FROM dbo.XMLTable(@Xml)
WHERE Value IS NOT NULL
--trim the trailing comma
SET @Cols = LEFT(@Cols, LEN(@Cols) -1)
--Generate dynamic SQL statement to pivot the rows from XMLTable function in a single row table
SELECT @SQL = 'SELECT ' + @Cols + '
FROM
(
SELECT XPath, Value
FROM dbo.XMLTable(@Xml)
WHERE Value IS NOT NULL
) x
PIVOT
(MAX(Value) FOR xpath IN (' + @Cols +')) y'
--Execute the statement
EXEC sys.sp_executesql @SQL, N'@Xml XML', @Xml = @Xml