Monday, March 26, 2012

replace value of ... variable

Hi
I have a variable @.IDENT. I'd like to change my data in XML and i use
replace value of (default value of .../DocumentRecId=0). I tried to do
in that way
UPDATE [Doc]
SET
doc_XML.modify('
replace value of (/DocumentDataSet/Document/DocumentRecId/text())[1]
with sql:variable("@.IDENT")')
FROM [dbo].[Document] AS [Doc]
WHERE doc_IDENT=@.IDENT
but I get errors.
"XQuery [dbo.Document.doc_XML.modify()]: The XQuery syntax
'/function()' is not supported."
Is there any posibilty to modify my data in XML using variables.
Greetings
RoanHello Roan,
R> I have a variable @.IDENT. I'd like to change my data in XML and i use
R> replace value of (default value of .../DocumentRecId=0). I tried to
R> do
R> in that way
R> UPDATE [Doc]
R> SET
R> doc_XML.modify('
R> replace value of
R> (/DocumentDataSet/Document/DocumentRecId/text())[1]
R> with sql:variable("@.IDENT")')
R> FROM [dbo].[Document] AS [Doc]
R> WHERE doc_IDENT=@.IDENT
This works for me:
drop table dbo.docs2
go
create table dbo.docs2(pkid tinyint identity(1,1),doc xml)
go
insert into dbo.docs2(doc) values ('<v>Some Value</v>')
go
declare @.v varchar(15)
set @.v= 'something else'
update dbo.docs2
set doc.modify('replace value of (/v/text())[1] with sql:variable("@.v")')
where pkid=1
go
select * from dbo.docs2
go
and so does set doc.modify('replace value of (/v/text())[1] with sql:column(
"pkid")').
With SP1. What version are you running (hint, what does @.@.version show?)
Thanks!
Kent Tegels
DevelopMentor
http://staff.develop.com/ktegels/|||thanks
I try tonight one more time and it wors...I think the problem was not
in replace value...
I have another question: this time i try to modify(add) value to node
like this
<DocumentNumberStyle />
I tryied to use replace value... but it doesn't work. Do you have any
idea have to do it.
Thanks for any help.
Roan|||Ok i solve the problem.
Greetings Roan

No comments:

Post a Comment