Click here to Skip to main content
15,173,272 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts,


I have a table called releasemaster

This table having data as follows:

SQL
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




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

SQL
 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 


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.
Posted
Updated 18-Aug-13 8:36am
v5
Comments
gvprabu 16-Aug-13 10:13am
   
See If you have 002.090.064 then 02.090.064 or 2.090.064...? and tel me one thing u need to check only first dot (.) before value or all values.
argeraju 18-Aug-13 13:20pm
   
Thanks Prabu for showing interest on my question.I want to check all dots(.) values.
For example if Client version is 001.080.012 then i want to display client version as 1.80.12 in the page.
actual column value column value to be display
010.980.089 10.980.89
100.765.908 100.765.908
100.010.089 100.10.89

SQL
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
   
Comments
argeraju 18-Aug-13 14:01pm
   
Thank you very much Tim Carmichael.I appreciated you.You did great job.It is working fine. I have tried to solve this issue in many ways but i didn't. You did it.
Maciej Los 18-Aug-13 16:41pm
   
+5!
Tim Carmichael 18-Aug-13 17:02pm
   
You're welcome, and thank you to you and Maciej Los.
DECLARE @strCV [nvarchar](26)
SET @strCV='002.091.118'
SELECT RIGHT(@strCV, LEN(@strCV)-PATINDEX('%.%',@strCV)+2)
   
v5
Comments
argeraju 18-Aug-13 14:14pm
   
Thanks ReDk. I appreciated you also.Actually i wanted to check the same thing for all dots(.)before value.You also answered for my question partially. With this also i got an idea to solve my problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900