CASTing Binary Values

  • Comments posted to this topic are about the item CASTing Binary Values

  • The same:

    SELECT 0x00006B61+0

  • I hope, this will be not the next Question of the Day, but sometimes you have the value not in a binary column but in a VARCHAR (e.g. because you imported it from an CSV).

    In this case:

       SELECT CAST(0x00006B61 AS INT)                           -- value is already a binary
    , CAST(CONVERT(BINARY(4), '0x00006B61', 1) AS INT) -- value is a varchar with leading 0x followed by a hex code
    , CAST(CONVERT(BINARY(4), '00006B61', 2) AS INT) -- value is a varchar without leading 0x (only the hex code)

    will do the job...

    God is real, unless declared integer.

  • Maybe you should write a few questions, Thomas ๐Ÿ˜‰

     

  • oh, I did already - about 20 questions ๐Ÿ™‚

    God is real, unless declared integer.

  • Nice question, thanks Steve

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    โ€œlibera tute vulgaris exโ€

Viewing 6 posts - 1 through 5 (of 5 total)

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