Home Forums SQL Server 2008 SQL Server Newbies EncryptByPassPhrase/DecryptByPassfrase, why don't this work? RE: EncryptByPassPhrase/DecryptByPassfrase, why don't this work?

  • I think you've got that query the wrong way around. You're comparing the encrypted column with the results of the decryption function. You should be comparing the decrypted value with the results of the decryption function applied to the column.

    Also, you're not specifying a length for char, you should. do you know what the default is?

    Something roughly like this

    select COUNT(*)

    from dbo.personal

    where Convert(Char[<whatever the string length is>,DecryptByPassPhrase('[PASSPHRASE]',CPR_encrypted)) =

    '070564-2869'

    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