Honorary member of the Shaolin

Quickie How-To for basic usage of xml datatype in SQL2K5

This was from an email I sent to some peeps for a quickie how-to...I was told that this kind of junk was worth posting on a blog.  Of course I want to do my part in cluttering up the world...

DECLARE @x as xml
SET @x = '<test att="1">
                  <node1 att="test att val node 1">test data 1</node1>
                  <node1 att="test att val node 2">test data 2</node1>
              </test>' --query a node set like a table
SELECT xd.rows.value('(.)','nvarchar(50)') AS result
FROM   @x.nodes('/test/node1') xd(rows)
--WHERE xd.rows.value('(.)','nvarchar(50)') LIKE '%test data 1'--to get values of attributes and nodes
select @x.value('(/test/@att)[1]', 'int' )--select @x.value('(/test/node1/@att)[1]', 'nvarchar(50)' )
--select @x.value('(/test/node1/@att)[2]', 'nvarchar(50)' )
select @x.value('(/test/node1)[1]', 'nvarchar(50)' )
--select @x.value('(/test/node1)[2]', 'nvarchar(50)' ) --to get nodes/sections/sets/doc fraagments
select @x.query('test/node1')

FYI, the way to dynamically create the xPath statement : use sql:variable to amend the xPath statement - if you try string concats you'll find this out ;-)

Technorati Tags: , , , ,
Comments are closed
All posts by mhouston


Honorary member of the Shaolin

Recovering a chromebook

Since Google’s Chromebook Recovery Utility doesn’t always work ;-{Here are some more ‘manual’ steps to ‘starting over’ :1) Find your image hereLook for your model device2)Use any img writer utility  to create USB or SD *Iused the raspberry PI img writer..any should work fine.  Some of the ... [More]

So true….

Some humor just isn’t funny anymore..

Using node.js on a Raspberry Pi Zero W for ‘remote control’ of GPIO–part 1/3

Setting up node.js on Raspberry Pi Zero W:1) SSH to your Raspberry Pi Zero W, execute :      ssh raspberryhostname –l pi2) Find the latest version of node.js for the armv61 architecture       search https://nodejs.org/dist/ for node-v[XX.X.X]-l... [More]