sql replace function for xml type column

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • msjonathan
    New Member
    • Dec 2009
    • 24

    sql replace function for xml type column

    I have a column "XML" as type xml in my database. And I want to replace some xml parameters.
    and I did this:
    Code:
    update core.Desktops
    set [xml] = replace(CAST([XML] as nvarchar(max)),
    '<property name="Name">colDepartments</property>
',
    '<property name="ColumnEditName">repDepartments</property>
')
    and it does not work, when I change the type of my column to text, or nvarchar it works. So I think it's all about the casting/ type of column.

    Do you have any tips to avoid this, a workaround, ....?

    I added the xml example in attachment.
    Attached Files
    Last edited by Niheel; Jun 1 '10, 08:53 AM. Reason: xml file to go with question
  • msjonathan
    New Member
    • Dec 2009
    • 24

    #2
    I found my problem , nvarchar(max) is only 8000 characters long. And the xml column exists out of 32000 characters. has anyone a solution for this problem, I can't cast xml to text.

    Edit: I was wrong varchar has a max of 8000, nvarchar has enough of characters

    Comment

    Working...