gpt4 book ai didi

mysql - 等效于 SQL Server 中的 MySQL HEX/UNHEX 函数?

转载 作者:行者123 更新时间:2023-11-29 05:12:02 31 4
gpt4 key购买 nike

SQL Server 是否具有与 HEXUNHEX MySQl 函数等效的功能?

最佳答案

2022 年更新:这已过时,阅读有关 CONVERT() 和二进制类型的信息

你要做什么?

类似脚本生成的东西?

对于您的问题可能有更好的方法,但您没有提供很多细节...

虽然没那么 slim ,但这样行得通

--This will show up like needed, but it will not be a string
SELECT CAST('abc' AS VARBINARY(MAX))

--this is the string equivalent
SELECT sys.fn_varbintohexstr(CAST('abc' AS VARBINARY(MAX)));

--This will turn the string equivalent back to varbinary
SELECT sys.fn_cdc_hexstrtobin('0x616263')

--And this will return the original string
SELECT CAST(sys.fn_cdc_hexstrtobin('0x616263') AS VARCHAR(MAX));

###一个提示

如果你处理 UNICODE 如果你设置 N'abc' 而不是 'abc' 并且在 den final 中你可以检查变化您必须将 '0x610062006300' 转换为 NVARCHAR 的行。

###另一个提示

如果你更频繁地需要它,你可以把它放到一个 UDF 中,而不是像 MySQL 那样简单:-)

关于mysql - 等效于 SQL Server 中的 MySQL HEX/UNHEX 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38121313/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com