在十六进制列中删除填充的零

编程入门 行业动态 更新时间:2024-10-26 20:28:51
本文介绍了在十六进制列中删除填充的零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在TSQL中有一个包含十六进制列的数据库。然而,这些值填充零以填充列。

我需要删除这些零,这样我才有十六进制字符串。问题是我不能只删除零对,因为字符串可能在零中间。

我有一种感觉,我需要将它转换为十进制,然后返回或者其他东西,但是我尝试的所有东西都会产生奇怪的结果。

数据库中的列看起来像这样:

1EBC67E6000000 6B1FE9C7830000 C700DBBF000000

值是不同的长度,所有填充零对。

任何想法都会很好!

解决

选择替换(rtrim(replace('C700DBBF000000')) ,'0','')),'','0');

I have a database in TSQL that contains columns in hexadecimal. However these values are padded with zeroes to fill the column.

I need to remove these zeroes just so I have the hexadecimal string. The problem is I cannot just remove pairs of zeroes as the string may have zeroes in the middle.

I have a feeling I need to convert it to say decimal and then back or something, but everything I try yields strange results.

The column in the database look like this:

1EBC67E6000000 6B1FE9C7830000 C700DBBF000000

The values are different lengths and all padded with pairs of zeroes.

Any ideas would be good!

解决方案

Maybe this will be good for you:

Select replace(rtrim(replace('C700DBBF000000','0',' ')),' ','0');

更多推荐

在十六进制列中删除填充的零

本文发布于:2023-10-27 18:30:29,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:十六进制列中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!