Search code examples
sqlsql-serverreporting-servicesssrs-2008

Displaying Hashbytes value in SSRS matrix


I have a simple query that I am trying to display the hashbytes value in an SSRS matrix - This throws an error when rendering the matrix

My Query

    select  hashbytes('md5',Consultant_Code) as Consultant_Code, 
    hashbytes('md5',Surgeon1_Code) as Surgeon_Code
    from TheatreOps

When this renders in preview view it displays #Error where I expect to see the value, has anyone had this before and could maybe suggest a fix please?


Solution

  • Use the following

    SELECT 
    '0x' + CONVERT(NVARCHAR(32),HashBytes('MD5', Consultant_Code),2) as Consultant_Code,
    '0x' + CONVERT(NVARCHAR(32),HashBytes('MD5', Surgeon_Code),2) as Surgeon_Code,
    FROM TheatreOps