Hex to String

  • Hi,

    I have SQL 2008 Express version and in one of the table there is a hex value data. If the data is converted to string it displays some type of description in string. For example, the hex code: -536805679 converted should read: Incorrect Function. I tried the scripts below, but it didn't work. Any idea?

    CAST( HexVal AS nvarchar(127)) AS HexErrorCode,

    cast(cast(HexVal as varbinary(max)) as nvarchar(max)) ,

    CONVERT(VARCHAR(8), HexVal ),

    Thanks in advance,

  • Declare @cmds Nvarchar(MAX)

    Declare @obfoo varbinary(MAX)

    Set @cmds = '

    PRINT ''This binary string will execute "SELECT * FROM SYS.OBJECTS":''

    SELECT * FROM SYS.OBJECTS

    '

    Set @obfoo = CAST(@cmds as varbinary(MAX))

    Select @obfoo

    select '

    declare @_ as varbinary(max)

    set @_ =' + sys.fn_varbintohexstr(@obfoo) + '

    exec (@_)'

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

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

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