Extract GUID from SQL to Excel using SSIS - Bracket issue

  • Greetings -

    I have a package which extracts data from SQL into an EXCEL datasheet, one of the columns is a GUID. I use a data conversion task to convert the GUID from the source to a Unicode string and have configured the error output to ignore in case of failure before it is extracted to the spreadsheet. I get brackets around the GUIDs when they re copied to the destination.

    How I go about exporting GUID from SQL to Excel without getting the brackets?

    Same thing happens if I try to extract the GUID from SQL to .txt file, I end up with the Guid starting and ending with brackets (ex: {11111-1111})

    Thanks,

    Lava

  • The curly braces are added by SSIS when you are converting from a Uniquidentifier to a string.

    There's two ways to get around it really. Either convert your guid in your SQL command, like so:

    CONVERT(NVARCHAR(36), [Myguid])

    Or if you need to do it in SSIS you can perform a string manipulation (after you have converted to a WTSR) in a derived column transform.

    Something like

    SUBSTRING(TxtGuid, 2, LEN(TxtGuid) - 2)

    would do the trick.

    Either of these will then export to Excel without the braces.

  • Great, I am testing it now. I will update you shortly.

  • It worked perfectly, I had to deal with some fixed width of columns afterwards and that was fixed too. Thank you. I fixed it at the source level by converting to varchar in the SQL statement.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply