BlobColumn to String

  • I have this column in sql server that has value of "dog,cat,mouse" so I want to fetch this data into SSIS then transform it into an array using script so I can loop through it but I'm having an error when doing so.

    var columnfromDB = "1,2,3"; // Need population so that Split won't throw an error

    if (Row.Animals != null)

    {

    columnfromDB = Row.Animals; // This is where the error comes from since Row.Animal is a BlobColumn

    string[] splittedString = columnfromDB.Split(',');

    }

    Any tips on how to solve this?

  • Use a query to get your data from SQL Server into SSIS and use CAST in the query to get the BLOB into string format

    DROP TABLE IF EXISTS #Blob;

    CREATE TABLE #Blob
    (
    SomeBLOB VARBINARY(MAX) NOT NULL
    );

    INSERT #Blob
    (
    SomeBLOB
    )
    VALUES
    (CAST('Dog,Cat,Mouse' AS VARBINARY(MAX)));

    SELECT b.SomeBLOB
    ,SomeText = CAST(b.SomeBLOB AS VARCHAR(8000))
    FROM #Blob b;

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

Viewing 2 posts - 1 through 1 (of 1 total)

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