Tutorial by Examples

SELECT 'Hello World' FOR XML PATH('example') <example>Hello World</example>
SQL Server 2008 WITH XMLNAMESPACES ( DEFAULT 'http://www.w3.org/2000/svg', 'http://www.w3.org/1999/xlink' AS xlink ) SELECT 'example.jpg' AS 'image/@xlink:href', '50px' AS 'image/@width', '50px' AS 'image/@height' FOR XML PATH('svg') <svg xmlns:xlink="http:...
SELECT 'XPath example' AS 'head/title', 'This example demonstrates ' AS 'body/p', 'https://www.w3.org/TR/xpath/' AS 'body/p/a/@href', 'XPath expressions' AS 'body/p/a' FOR XML PATH('html') <html> <head> <title>XPath example</title> &...
The FOR XML PATH can be used for concatenating values into string. The example below concatenates values into a CSV string: DECLARE @DataSource TABLE ( [rowID] TINYINT ,[FirstName] NVARCHAR(32) ); INSERT INTO @DataSource ([rowID], [FirstName]) VALUES (1, 'Alex') ,(2, 'Peter') ...

Page 1 of 1