Delen via


Voorbeeld: Binaire gegevens ophalen

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

De volgende query retourneert de productfoto die is opgeslagen in een kolom met het type varbinary(max). De BINARY BASE64 optie wordt opgegeven in de query om de binaire gegevens in base64-gecodeerde indeling te retourneren.

Example

USE AdventureWorks2022;
GO
SELECT ProductPhotoID, ThumbNailPhoto
FROM Production.ProductPhoto
WHERE ProductPhotoID = 1
FOR XML RAW, BINARY BASE64;
GO

Verwacht het volgende resultaat:

<row ProductModelID="1" ThumbNailPhoto="base64 encoded binary data"/>

Zie ook

RAW-modus gebruiken met FOR XML