Archive for August, 2007
SQL to XML
by gregs on Aug.29, 2007, under MS SQL
Just came across this neat trick that uses SQL to generate XML on the fly:
CODE:
-
DECLARE @x xml
-
SET @x=(select geoAreaCode
-
, geoLevelCode
-
, geoLevelId
-
, geoAreaId
-
from tbl_geoLevel
-
where uuid =
-
for xml raw('geoArea'), root('geoAreas'), type)
-
SELECT @x AS geoAreaInfo
The above will create an XML structure that has a root value of geoAreas and child elements of geoArea for each row found.