Re: Convert NTEXT to XML for use in following query.
- From: Kent Tegels <ktegels@xxxxxxxxxxx>
- Date: Mon, 13 Aug 2007 17:41:20 +0000 (UTC)
Hello Robin,
However, sometimes I'm sending a lot of IDs (possibly a few thousand)
and the resulting XML document seems to become truncated. i.e. if I
send 1,000, I will get back 950 records. What I would like to do is
pass in an NTEXT field and convert this to XML in order to do the join
on the full set. Any ideas how I do this?
Here's one way to do that.
use scratch
go
create table dbo.objects(id int,descr nvarchar(200))
create table dbo.ids(list ntext)
go
insert into dbo.objects values (1,'apple')
insert into dbo.objects values (2,'banana')
insert into dbo.objects values (3,'cherry')
insert into dbo.objects values (4,'durian')
go
insert into dbo.ids(list) values ('<ids><id>1</id><id>2</id><id>3</id><id>4</id></ids>')
go
declare @x xml
select @x = list from dbo.ids
;with l(id) as (select t.c.value('.','int')
from @x.nodes('//id') as t(c))
select l.id,o.descr from l join dbo.objects o on l.id = o.id
go
drop table dbo.ids
drop table dbo.objects
go
Thanks!
Kent Tegels
DevelopMentor
http://staff.develop.com/ktegels/
.
- Follow-Ups:
- Re: Convert NTEXT to XML for use in following query.
- From: Robin Tucker
- Re: Convert NTEXT to XML for use in following query.
- References:
- Convert NTEXT to XML for use in following query.
- From: Robin Tucker
- Convert NTEXT to XML for use in following query.
- Prev by Date: Re: Passing XML between 2005 and 2000
- Next by Date: Re: Passing XML between 2005 and 2000
- Previous by thread: Convert NTEXT to XML for use in following query.
- Next by thread: Re: Convert NTEXT to XML for use in following query.
- Index(es):
Relevant Pages
|