How to convert SQL Server uniqueidentitifer type to string?

I’m using the extension xk6-sql to read some data from SQL Server database.
The value retrieved from database is a byte array.
How can i convert it to a string?

Hi @lommez,
welcome to the community forum :tada:

The UniqueIdentifier type seems directly supported from the CAST/CONVERT function.

Something like the following example should work:

SELECT convert(nvarchar(50), ID) FROM Customers

If SQL is not an option for you then you should create a conversion function. You can use as an example the String function from the mssql library.

1 Like

Thank you @codebien !