SELECT fails with "Data would be truncated" during Decryption

  • A column in the database had Assymetric Encryption applied to it. A bunch of data got pumped into the column (nvarchar(max)) and now while trying to use the DecryptByAsymKey() function the query fails with "String or Binary data would be truncated".

    This is the column in the SELECT:

    CONVERT(varchar(max),DecryptByAsymKey(AsymKey_ID('Asym_Key'),tableColumn, N'$#@HJK$J$#')) AS DataColumn

    If I remove this and just put the tableColumn in raw form the query works.

    HELP HELP! With varchar(max) specified for the conversion, why would it truncate????

    Thanks,

    Tom

  • What's the data type of the column in the table?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • This problem usually occurs when you are trying to get data into a space into which it will not fit. I'd actually recommend exporting this data (and decrypting), then bringing it back in and making it fit the space.

    I think that CONVERT is limited to 8k.

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

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