varbinary 的长度 [英] len of varbinary
问题描述
有人能解释一下为什么 select len(0x0a000b) 返回 3 吗?len 计算字节数吗?为什么 select left(0x0a000b, 1) 什么都不返回?我期望 0x0a(如果 len 计算字节)...
我使用的是 mssql 2005
谢谢康斯坦丁
select len(0x0a000b)
返回由三个字节 0x0a、0x00 和 0x0b 表示的字符串的长度.>
select left(0x0a000b, 1)
返回字符串最左边的字符,即换行符.
注意 select case when left(0x0a000b, 1) = 0x0a then 1 else 0 end
返回 1
,这表明您确实正在获取换行符.
有关其他详细信息,请参阅下面的评论.
would someone please explain why select len(0x0a000b) returns 3? does len count bytes? and why select left(0x0a000b, 1) returns nothing? i expected 0x0a (if len counts bytes)...
i am using mssql 2005
thanks konstantin
select len(0x0a000b)
is returning the length of a string represented by the three bytes 0x0a, 0x00, and 0x0b.
select left(0x0a000b, 1)
returns the left-most character of the string, which is a newline character.
Note that select case when left(0x0a000b, 1) = 0x0a then 1 else 0 end
returns 1
, which indicates you are, indeed, getting the newline character.
Edit: Please see the comments below for additional details.
这篇关于varbinary 的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!