Hope This helps.

http://msdn2.microsoft.com/en-us/library/ms191530.aspx#_binary

You can convert int, smallint, and tinyint to binary or varbinary, but 
if you convert the binary value back to an integer value, this value 
will be different from the original integer value if truncation has 
occurred. For example, the following SELECT statement shows that the 
integer value 123456 is usually stored as a binary 0x0001e240:

SELECT CAST( 123456 AS BINARY(4) )

However, the following SELECT statement shows that if the binary target 
is too small to hold the entire value, the leading digits are silently 
truncated so that the same number is stored as 0xe240:

SELECT CAST( 123456 AS BINARY(2) )




David wrote:
> Hi,
> 
> I've checked the SQL Server references, and haven't found.
> 
> I have a varchar field, which has a bitmask (7 ones and zeros, like 0111100
> - days of week) and would like in SQL to convert to int.
> 
> Is there a T-SQL function to do a base-2 conversion of varchar to int?
> 
> Thanks,
> - David
> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/cf_lists/message.cfm/forumid:6/messageid:2511
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:6
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.6

Reply via email to