• Thanks Lynn, your code is clarifying. Still I'm confused as to why results display different. I probably don't get the different charsets involved? Any help welcome.

    If I run your code and choose the first 2 columns:
    TestVal                               TestValHash
    qwertyuiopasdfghjklz                   0x3B7D1943F03E8ACFED7AB74E895B59920D75CB78BA682247A487498E26DBC0AB

    TestValHash is, precisely with this format, what I would like to see and store in my target table  (this is also what every other software I know  -e.g. R- produces when you run SHA256('qwertyuiopasdfghjklz')   ).

    If I try to build this with my own T-SQL code:

    --source table with ids
    CREATE TABLE nonhashed (
    id varchar(20) ) ;
    INSERT INTO nonhashed(id)
    VALUES('qwertyuiopasdfghjklz') ;

    --target table with hashes
    CREATE TABLE hashed (
    id varchar(20),
    sha256 varchar(280) ) ;

    --using ASCII code for hashed table?
    INSERT INTO hashed(id, sha256)
    SELECT id, HASHBYTES('SHA2_256', CONVERT(varchar(20), id) )
    FROM [nonhashed] ;

    the output is:
    id    sha256
    qwertyuiopasdfghjklz    ;}C?>???z·N‰[Y’u?x?h"G¤‡I?&??«

    So, as simply as I can put it, I'd like to see stored the same as before, with the variable. I don't get if my problem is:

    • How SSIS displays information (internally the unreadable sha256, and the readable one, are the same)
    • The definition of the source/target tables (insufficient lenght of fields causing truncating)
    • Or that HASHBYTES produces different output when you use it on a table, or on a variable.