|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Predicate value when retrieving a valueExample: DECLARE @XmlData xml ,@Predicate int ,@Value nvarchar (65) SELECT @XmlData = '<DocumentPacket> <Party> <Number>1000</Number> <ModeOfTransportation> <Code>40</Code> <Description>Air</Description> </ModeOfTransportation> </Party> <Party> <Number>2000</Number> <ModeOfTransportation> <Code></Code> <Description></Description> </ModeOfTransportation> </Party> </DocumentPacket>' SET @Predicate = 1 -- This works fine. SELECT @Value = @XmlData.value('(/DocumentPacket/Party/Number)[1]', 'nvarchar(65)') -- I want to do something like this, is this possible? SELECT @Value = @XmlData.value('(/DocumentPacket/Party/Number)[sql:variable("@Predicate")]', 'nvarchar(65)') Hello Loren,
> Is it possible to have the predicate value a variable. Sure, you almost had it:SELECT @Value = @XmlData.value('(/DocumentPacket/Party/Number)[sql:variable("@predicate")][1]', 'nvarchar(65)') Thanks! Kent Tegels DevelopMentor http://staff.develop.com/ktegels/ Thank-you, it also works for me now.
Show quote "Kent Tegels" <kteg***@develop.com> wrote in message news:18f2bcb129e248c9da31d6d34cd0@news.microsoft.com... > Hello Loren, > >> Is it possible to have the predicate value a variable. > > Sure, you almost had it: > > SELECT @Value = > @XmlData.value('(/DocumentPacket/Party/Number)[sql:variable("@predicate")][1]', > 'nvarchar(65)') > > Thanks! > Kent Tegels > DevelopMentor > http://staff.develop.com/ktegels/ > > |
|||||||||||||||||||||||