如何将字符串转换为十六进制,反之亦然? [英] How to convert a String to Hex and vice-versa?
本文介绍了如何将字符串转换为十六进制,反之亦然?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如您所知,在MySQL中,我们有HEX& UNHEX,例如当我这样写时:
As you know , in MySQL we have HEX & UNHEX, for example when I write like this :
select hex("Ali");
转换结果是:416C69
the convert result is : 416C69
和十六进制是这样的:select unhex("416C69");
and the unhex is like this : select unhex("416C69");
在MSSQL中,我无法将其转换,能否请给我两个示例?
In MSSQL I can't convert this, could you please give me an example for both of them ???
非常感谢...
推荐答案
我认为这应该有效
SELECT hex(CAST("Ali" AS VARBINARY)) AS Expr1
反之亦然
select CONVERT(varbinary(max), "416C69");
这将转换为varbinary,然后您可以将varbinary转换为varchar
This will convert to varbinary, then you can convert varbinary to varchar
这篇关于如何将字符串转换为十六进制,反之亦然?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文