How do I escape double quotes in attributes in an XML String in T-SQL?

后端 未结 4 561
予麋鹿
予麋鹿 2020-12-23 13:17

Pretty simple question - I have an attribute that I would like to have double quotes in. How do I escape them? I\'ve tried

  • \\\"
  • \"\"
  • \\\\\"
4条回答
  •  时光说笑
    2020-12-23 13:20

    tSql escapes a double quote with another double quote. So if you wanted it to be part of your sql string literal you would do this:

    declare @xml xml 
    set @xml = ""
    

    If you want to include a quote inside a value in the xml itself, you use an entity, which would look like this:

    declare @xml xml
    set @xml = ""
    

提交回复
热议问题