I have a MS SQL 2008 R2 Standard database. I have a column with varchar(250)
data and a column with xml
.
CREATE TABLE [dbo].[art](
[id] [int] IDENTITY(1,1) NOT NULL,
[idstr] [varchar](250) NULL,
[rest] [xml] NOT NULL,
CONSTRAINT [PK_art] PRIMARY KEY CLUSTERED ([id] ASC)
)
The problem is I want to insert result of a string function into into xml, in about 140 records. I've tried to use xml.modify
with dynamically generated text.
UPDATE [pwi_new].[dbo].[art]
SET rest.modify('insert <e><k>link</k><v>'
+ my_string_function(idstr) + '</v></e> into (/root)[1]')
WHERE parent = 160
AND idstr LIKE '%&%'
GO
However, I've got this error:
The argument 1 of the XML data type method "modify" must be a string literal.
Any ideas? I'd like to avoid using temporal fields, external languages and executing TSQL from generated string? (I've heard of sql:variable
and sql:column
, but this is a result of tsql function.)