Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
lleoun
Starting Member
2 Posts |
Posted - 2011-11-11 : 07:08:50
|
| Hi all, I have a table containing a very long xml field. I need to update that xml adding a readonly in an xsl input like that:From<input type="text" id="doc" name="doc" maxlength="15">To<input type="text" id="doc" name="doc" maxlength="15" readonly="readonly">How can I do that?Thanks a million |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-11 : 07:16:20
|
use modify() methodUPDATE tableSET xmlcol.modify('insert attribute readonly{"readonly"} into (//input)[1]')------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
lleoun
Starting Member
2 Posts |
Posted - 2011-11-11 : 07:19:59
|
| amazing! thanks a million!! |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2011-11-11 : 07:55:04
|
quote: Originally posted by visakh16
UPDATE tableSET xmlcol.modify('insert attribute readonly{"readonly"} into (//input)[1])')
Please notice that INSERT will create a duplicate attribute if already present. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-11 : 08:53:05
|
quote: Originally posted by SwePeso
quote: Originally posted by visakh16
UPDATE tableSET xmlcol.modify('insert attribute readonly{"readonly"} into (//input)[1])')
Please notice that INSERT will create a duplicate attribute if already present. N 56°04'39.26"E 12°55'05.63"
I know that In the sample XML OP posted there was no readonly attribute already------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-11 : 09:05:55
|
quote: Originally posted by SwePeso
quote: Originally posted by visakh16
UPDATE tableSET xmlcol.modify('insert attribute readonly{"readonly"} into (//input)[1])')
Please notice that INSERT will create a duplicate attribute if already present. N 56°04'39.26"E 12°55'05.63"
If at all there's already an attribute readonly, then following should handle itUPDATE tableSET xmlcol.modify('insert if (count(//input[@readonly]) =0)then attribute readonly{"readonly"} else ()as lastinto (//input)[1]')------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|