Delen via


Voorbeeld: De CDATA-instructie opgeven

van toepassing op:SQL ServerAzure SQL DatabaseAzure SQL Managed InstanceSQL-database in Microsoft Fabric

Als de instructie is ingesteld op CDATA, worden de ingesloten gegevens niet gecodeerd, maar in de sectie CDATA geplaatst. De CDATA-kenmerken moeten naamloos zijn.

De volgende query verpakt de beschrijving van het productmodeloverzicht in een CDATA-sectie.

USE AdventureWorks2022;
GO
SELECT  1 as Tag,
        0 as Parent,
        ProductModelID  as [ProductModel!1!ProdModelID],
        Name            as [ProductModel!1!Name],
        '<Summary>This is summary description</Summary>'
            as [ProductModel!1!!CDATA] -- no attribute name so ELEMENT assumed
FROM    Production.ProductModel
WHERE   ProductModelID = 19
FOR XML EXPLICIT;

Dit is het resultaat:

<ProductModel ProdModelID="19" Name="Mountain-100">
   <![CDATA[<Summary>This is summary description</Summary>]]>
</ProductModel>

Zie ook