Domanda abbastanza semplice - Ho un attributo che mi piacerebbe avere doppie virgolette in. Come faccio a fuggire da loro? Ho provatoCome faccio a evitare le doppie virgolette negli attributi in una stringa XML in T-SQL?
- \ "
- ""
- \\"
e ho fatto la variabile atributo @xml sia di tipo xml e varchar (max) per tutti loro .
declare @xml xml --(or varchar(max) tried both)
set @xml = '<transaction><item value="hi "mom" lol"
ItemId="106" ItemType="2" instanceId="215923801" dataSetId="1" /></transaction>'
declare @xh int
exec sp_xml_preparedocument @xh OUTPUT, @xml
insert into @commits --I declare the table, just removed it for brevity
select
x.*
from openxml(@xh,'/transaction/item')
WITH (
dataItemId int,
dataItemType int,
instanceId int,
dataSetId int,
value varchar(max)
) x
A proposito ... non c'è alcun motivo (AFAIK) per usare openxml qui ... cioè cose "pre-2005". Se hai un valore xml, usalo direttamente come xml. –
Marc - Grazie. Ho avuto un altro bug che ha finito con l'essere openxml che stava scoppiando con gli apostrofi ricci: 'Penso che lo posterò come una domanda/risposta per trovare Google. –