problem with data conversion.....

  • Hi,

    plz see dis simple script. What's going wrong with the varbinary data while converting to float?? Here I used the built-in encryption-decryption functions in 2005 which returns varbinary.

    Plz help

    declare @a varbinary(100)

    declare @b-2 varbinary(100)

    declare @f float

    set @f=123.456

    set @a=EncryptByPassPhrase('vival', cast(@f as varbinary))

    set @b-2=DecryptByPassPhrase('vival', @a)

    print @b-2

    print cast(cast(@b as decimal(10,4)) as float)

  • As a guess, another case where float's inaccuracy gives problems. The number been cast back to decimal probably has too many decimal places to fit in the specified scale.

    If you declare @f as a decimal, it works fine.

    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

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

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