can't insert xml dml expression as a string
Posted
by 81967
on Stack Overflow
See other posts from Stack Overflow
or by 81967
Published on 2010-03-30T09:22:18Z
Indexed on
2010/03/30
11:33 UTC
Read the original article
Hit count: 330
sql-server-2005
|xml-dml
Here is the code below that would explain you the problem...
I create a table below with an xml column and declare a variable, initialize it and Insert the Value into the xml column,
create table CustomerInfo
(XmlConfigInfo xml)
declare @StrTemp nvarchar(2000)
set @StrTemp = '<Test></Test>'
insert into [CustomerInfo](XmlConfigInfo)
values (@StrTemp)
Then comes the part of the question,, if I write this...
update [CustomerInfo] set XmlConfigInfo.modify('insert <Info></Info> into (//Test)[1]')
-- Works Fine!!!
but when I try this,
set @StrTemp = 'insert <Info></Info> into (//Test)[1]'
update [CustomerInfo] set XmlConfigInfo.modify(@StrTemp)
-- Doesn't Work!!!
and throws an error
The argument 1 of the xml data type method "modify" must be a string literal.
is there a way around for this one?
I tried this, but it is not working :(
© Stack Overflow or respective owner