将二进制 ID 字段转换为文本 [英] Convert Binary Id Field to Text
本文介绍了将二进制 ID 字段转换为文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要 SQL Server 2005 中 id 字段的文本(表示).有没有办法,我们可以生成 id 字段的文本表示?
I need the text (representation) of a id field in SQL Server 2005. Is there a way, we can generate the textual representation of the id field?
例如,如果 id 字段读取为 0x00000000000002F0,我需要 0x00000000000002F0 的文本值,以便我可以运行 SUBSTR 操作.
For instance, if the id field reads as 0x00000000000002F0, I need the text value of 0x00000000000002F0 so that I can run SUBSTR operations on the same.
约束
- 我不允许在数据库中创建存储过程(因为不允许创建 SP)
谢谢!
推荐答案
您可以使用
SELECT CONVERT(VARBINARY(40),N'Hello World')
(returns 0x480065006C006C006F00200057006F0072006C006400)
使用
SELECT CONVERT(NVARCHAR(20), 0x480065006C006C006F00200057006F0072006C006400)
(returns 'Hello World')
这篇关于将二进制 ID 字段转换为文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文