| Michael Rys [MSFT] 2005-09-06, 1:25 pm |
| Do you need to do a transformation or an in-place replace?
In either case, you would need to use XQuery in the following way:
Let's assume that the XML is in a variable @x:
select @x.query('<vehicles>{/transport/node()}</vehicles>')
would do the transform.
set @x = @x.query('<vehicles>{/transport/node()}</vehicles>')
(applying the above to table columns and adding support for attributes is
left as an exercise to the reader).
We do not have a rename functionality in the DML in this release.
Best regards
Michael
<firechaser@talk21.com> wrote in message
news:1125992983.590477.141270@g44g2000cwa.googlegroups.com...
> I'd like to be able to rename the element 'transport' to 'vehicles'
>
> <transport>
> <cars />
> <tractors />
> <buses />
> <planes />
> </transport>
>
> |
> |
> V
>
> <vehicles>
> <cars />
> <tractors />
> <buses />
> <planes />
> </vehicles>
>
> Is this possible via sql 2005's subset of xquery?
>
> I thought about copying the attributes & elements of <transport> into a
> new element called 'vehicles' inserting it above <transport> and then
> deleting the latter but isn't that a bit clunky especially if
> <transport> has thousands of nodes? It would mean a lot of unneccesary
> processing and copying in/out ram just to change two strings i.e.
> opening and closing element tags.
>
> Anyone with ideas?
>
> Thanks,
> Peter
>
|