在十六进制列中删除填充的零 [英] Removing padded zeroes in Hexadecimal column

查看:173
本文介绍了在十六进制列中删除填充的零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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');

这篇关于在十六进制列中删除填充的零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆