日期:2014-05-18  浏览次数:20482 次

BT的BINARY转换问题
我现在遇到一个SQL的问题,我们客户要在存储过程中取一个binary类型的字段的48位的一个值并转换为VARCHAR(1)请问能实现吗?怎么实现.
如:  
Declare   @Options   binary(100)
Select  
@Options=CLEI.Options
from  
CWORKORDER   cw   inner   join   CustomerLEI   CLEI   on   Cw.BillToCustomerCode=CLEI.Code  
Where
CW.workorder= 'BT345896 '
要去@Optins的地48为的值(这里暂时把@Options当字符串)
谢谢了


------解决方案--------------------
example:
-------------------------------
declare @Options varbinary(4000)

set @Options=0x1212323123123123123A

select substring(cast(@Options as varchar(8000)),5,1)

/*
----
#
*/
------解决方案--------------------
Select
CAST(SUBSTRING(CLEI.Options,6,1) AS INT)%2 AS FLAG,CLEI.Options
from
CWORKORDER cw inner join CustomerLEI CLEI on Cw.BillToCustomerCode=CLEI.Code