我有一个过时的4GL应用程序,该应用程序将ID保持为二进制格式,而没有进行任何加密。 我已经尝试了简单的CAST AS INT,CAST(SUBSTRING(..,3,1000)AS INT),因此无济于事。可以请教吗?
在binary_source列下面的示例中,有一个来自SQL Server的示例数据,correct_result是一个结果,结果显示在4GL应用程序中,介于两次之间。
WITH binary_to_convert AS
(
SELECT 0x1841506A00000000 AS binary_source,100005 AS correct_result
UNION ALL SELECT 0x1841506A00000000,100005
UNION ALL SELECT 0x1841506A00000000,100005
UNION ALL SELECT 0x1841506A00000000,100005
UNION ALL SELECT 0x1841506A00000000,100005
UNION ALL SELECT 0x1841706A00000000,100007
UNION ALL SELECT 0x1841706A00000000,100007
UNION ALL SELECT 0x1841906A00000000,100009
UNION ALL SELECT 0x1841906A00000000,100009
UNION ALL SELECT 0x1841706A00000000,100007
UNION ALL SELECT 0x1841706A00000000,100007
UNION ALL SELECT 0x1841706A00000000,100007
UNION ALL SELECT 0x1841706A00000000,100007
UNION ALL SELECT 0x1841706A00000000,100007)
SELECT b.binary_source,
cast(b.binary_source AS INT) AS INT_COLUMN,
CAST(SUBSTRING(b.binary_source,3,1000) AS VARCHAR(MAX)) AS VARCHAR_COLUMN,
CAST(SUBSTRING(b.binary_source,3,1000) AS INT) AS INT_CAST_COLUMN,
b.correct_result
FROM binary_to_convert b