• Steve, I love these questions. Thanks:-D

    Oh, here is an excerpt of a UDF I used to convert from int to binary (of course the other aspects of the UDF is checking the data type). I'm sure many of you use something similar or SQL Server bitwise ANDs. Just thought I'd share.

    Thanks

    --Convert to "binary"\HEX

    select CONVERT(binary,2014), CONVERT(varbinary,2014)

    --Returns 0x7DE...of course, the actual result between the two are different (fixed vs. variable)

    --Convert string value to true binary representation

    declare @parmVal int

    declare @currVal varchar(64)

    declare @counter int

    set @parmVal=2014

    select @counter = 64, @currVal = ''

    while @counter>0

    begin

    select @currVal = convert(char(1), @parmVal % 2)+@currVal

    select @parmVal = convert(int, (@parmVal / 2))

    select @counter=@counter-1

    end

    select @currVal

    --Returns 11111011110 (I left off the prepended 0's)