You are here: Re: Query out an xml element from a field containing xml data « MsSQL Server « IT news, forums, messages
Re: Query out an xml element from a field containing xml data

Posted by Mike on 01/26/06 18:26

What you could do, is write a user defined function. Something like

create function [dbo].[fn_GetText]
(
@Text as XML
)
returns varchar(50)
begin
declare @Result as varchar(50)
declare @Count as int
declare @Start as int

set @Count = 1
set @Start = 0

while @Count <= len(@Text)
begin
if substring(@Text, @Count, 6) = '<test>'
set @Start = @Count + 6

if substring(@Text, @Count, 7) = '<\test>' and @Start <> 0
set @Result = substring(@Text, @Start, @Count - @Start - 1)

set @Count = @Count + 1
end

return @Result
end

go

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация