22,209
社区成员
发帖
与我相关
我的任务
分享
;WITH a(BCD) AS (
SELECT 0x78563412
),
b(s) AS (
SELECT SUBSTRING(sys.fn_varbintohexstr(BCD),3,8)
FROM a
),
c(value) AS (
SELECT CONVERT(float,
SUBSTRING(s,7,2)+
SUBSTRING(s,5,2)+
SUBSTRING(s,3,2)+'.'+
SUBSTRING(s,1,2))
FROM b
)
SELECT * FROM c
value
----------------------
123456.78
with a3 as
(
select SUBSTRING((select CAST(78563412.0 as varchar(20)) as a1),7,2)as a2,1 as id
),
b3 as
(
select SUBSTRING((select CAST(78563412.0 as varchar(20)) as b1),5,2)as b2 ,1 as id
),c3 as
(
select SUBSTRING((select CAST(78563412.0 as varchar(20)) as c1),3,2)as c2 ,1 as id
),d3 as
(
select SUBSTRING((select CAST(78563412.0 as varchar(20)) as d1),1,2)as d2 ,1 as id
)
select e3 from ( select a3.a2,b3.b2,c3.c2,d3.d2,(a2+b2+c2+'.'+d2) as e3 from a3,b3,c3,d3 where a3.id=b3.id) as f2