sql server 插入binary数据
插入
insert into [dbo].[t_binary]([key], [binarychr]) values('003', 0x1189)
查询
select [key],CONVERT(binary(10), [binarychr]) from [t_binary]
结果
0030x11202020202020202020
为什么插入0x1189,结果变成0x1120了?
其中:binarychr char(10)
[解决办法]
因为做了类型转换。
create table t_binary([key] char(10), [binarychr] char(10))insert into [dbo].[t_binary]([key], [binarychr]) values('003', 0x1189)select [key],CONVERT(binary(10), [binarychr]) from [t_binary]/*003 0x11202020202020202020*/create table t_binary1([key] char(10), [binarychr] binary(2))insert into [dbo].[t_binary1]([key], [binarychr]) values('003', 0x1189)select [key],[binarychr] from [t_binary1]/*key binarychr---------- ---------003 0x1189*/