KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Table is named as MasterTable Columns ID type BIGINT , Name type VARCHAR(200) (stores xml type data for some reasons) Name contains data structured as <en-US>SomeEnglishText</en-US><it-IT>SomeItalicText</it-IT> When I need to Update the Master Table then at that time I Need to cast the Varchar to xml then conditionally update / replace the value part of particular tag i.e either en-US / it-IT . Also there are chances that No data/tags are there in Name column so I think at the time of Inserting data it would Insert empty tag elements in the table like <en-US></en-US><it-IT></it-IT> , so the update query must handle empty value in tag elements namely en-US/it-IT . I am trying to do it like following update query. DECLARE @Str VARCHAR(200) SET @Str = 'Test Text' UPDATE [MasterTable] SET [Name] = cast([MasterTable].[Name] as xml).modify('replace value of (en-US/text())[1] with sql:variable("@Str")') WHERE [ID]=18 I getting following error when running the query Illegal use of xml data type method 'modify'. A non-mutator method is expected in this context.
Tags (comma-separated)
Save Edits
Cancel