问题描述
子字符串如何处理十六进制值?
How does substring work on hexadecimal values?
看到这个:
PRINT SUBSTRING(0x6,1,1)
PRINT SUBSTRING(0xF6,1,1)
PRINT SUBSTRING(0xFF6,1,1)
PRINT SUBSTRING(0xFFF6,1,1)
...输出...
0x06
0xF6
0x0F
0xFF
...目前在我看来完全是无稽之谈.但它可以以某种方式用于检测触发器中更新的列(参见 COLUMNS_UPDATED().
...which currently looks as a complete nonsense to me. But it can somehow used in detecting which column is updated in trigger (see COLUMNS_UPDATED()).
我试过了:
- 将其中间转换为字符串,然后对其进行子字符串化
- 将其中间转换为int,然后是字符串,然后是子字符串
- 在 MSDN substring() 文档中搜索
- 谷歌搜索
谁能解释一下这种转换是如何完成的?
Can someone explain how is that conversion done?
推荐答案
SUBSTRING
文档 并不是特别清楚它如何处理二进制值,指的是字符"而不是字节.但它有效地将输入视为一个字节序列,并且使用 1, 1
您要求的是序列的第一个字节:
The SUBSTRING
documentation isn't particularly clear about how it treats binary values, referring to 'characters' rather than bytes. But it's effectively treating the input as a byte sequence, and with 1, 1
you are asking for the first byte of the sequence:
Input Byte sequence
----------------------
0x6 06
0xF6 F6
0xFF6 0F F6
0xFFF6 FF F6
SUBSTRING(input, 1, 1)
的输出:
0x06
0xF6
0x0F
0xFF
这篇关于SUBSTRING() 和十六进制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!