SQL Server二进制文件(128)从little endian转换为big endian

时间:2010-03-10 11:47:06

标签: sql-server tsql endianness

如何在SQL Server中将二进制文件(128)从小端转换为大端?

1 个答案:

答案 0 :(得分:11)

尝试这样的事情:

declare @little binary(4)
set @little = 0x02010000

select
  @little [bigEndian],
  cast(reverse(@little) as binary(4)) [littleEndian]

输出:

bigEndian  littleEndian
---------- ------------
0x02010000 0x00000102

(1 row(s) affected)