Hi @Sander van de Velde
The value is in UTF8 byte format.
I created a UDF in C# and ran the below query in VS Code with ASA extension
public static string GetStringFromUtf8(byte[] input)
{
try
{
return Encoding.UTF8.GetString(input);
}
catch (Exception e)
{
return e.Message;
}
}
SELECT * , udf.ByteToString(GetMetadataPropertyValue(InputEH, '[User].[CorrelationId]')) as converted, GetMetadataPropertyValue(InputEH, '[User]') AS userprops , GetMetadataPropertyValue(InputEH, 'EventHub') AS ehprops INTO [OutputEgress] FROM [InputEH]
But I got the below error caz function is expecting the varbinary(max)
So I tried to use the casting like below. But varabinary(max) it returns null and varchar(max) return System.Byte[].
SELECT *
, TRY_CAST(GetMetadataPropertyValue(InputEH, '[User].[CorrelationId]') as nvarchar(MAX)) as CorrelationIdVarChar
, TRY_CAST(GetMetadataPropertyValue(InputEH, '[User].[CorrelationId]') as varbinary(MAX)) as CorrelationIdVarBinary
, GetMetadataPropertyValue(InputEH, '[User]') AS userprops
, GetMetadataPropertyValue(InputEH, 'EventHub') AS ehprops
INTO [OutputEgress] FROM [InputEH]
Not sure what else I need to try to get the string out of the byte[]