本文介绍了如何从所有行的单个列值中删除前导零。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家,





我有一张名为releasemaster的桌子



此表的数据如下:



Hi Experts,


I have a table called releasemaster

This table having data as follows:

releaseid	  clientversion	     serviceversion	                databaseversion
116	     002.091.118	       2.91.124	                   0.40
117	     002.091.108	       2.91.114	                   0.30
118	     002.091.100	       2.91.106	                   0.28









我想删除clientversion列前导零:



例如我有Clientversion (varchar字段)值为000.090.064

我想将clientversion值显示为0.90.64







I want to remove the clientversion column leading zeros:

For example i have Clientversion(varchar field) value as 000.090.064
I want to display clientversion value as 0.90.64

 Actual column value                column value to be display 
000.123.090                                          0.123.90
090.123.090                                          90.123.90
900.080.001                                          900.80.1
900.897.000                                          900.897.0
002.009.009                                          2.9.9 





如何使用select语句获取该格式的客户端版本列值。



请帮我解决这个问题,我将非常感谢。



How can i get the client version column value in that format by using the select statement.

Please help me out with this issue , i will appreciate you.

推荐答案

select release_id,
convert(varchar, convert(int, PARSENAME(clientversion,3))) + '.' +
convert(varchar, convert(int, PARSENAME(clientversion,2))) + '.' +
convert(varchar, convert(int, PARSENAME(clientversion,1))) as ClientVersion,
serviceversion,
databaseversion from releasemaster


DECLARE @strCV [nvarchar](26)
SET @strCV='002.091.118'
SELECT RIGHT(@strCV, LEN(@strCV)-PATINDEX('%.%',@strCV)+2)


这篇关于如何从所有行的单个列值中删除前导零。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 18:12