Cast as varbinary?

  • I need the hex digits of a column, I had the code before but forgot it.

    EXAMPLE:

    SELECT COL1, COL1 as varbinary FROM TABLE

    RESULTS:

    CAT, 0x0324324324432 <--- something like that

  • What's wrong with using CAST?

    SELECT 'CAT', CAST( 'CAT' AS varbinary)

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Check function CONVERT in BOL.

    SELECT CONVERT(char(50), CAST(113 AS binary(4)), 1) AS c1;

    GO

  • you basically have the answer in the title.

    create table #tmp(col1 varchar(10))

    INSERT INTO #tmp

    values('CAT')

    SELECT col1,cast(col1 as varbinary(max))

    from #tmp

    Bob
    -----------------------------------------------------------------------------
    How to post to get the best help[/url]

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

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