Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Prefix Zero

Author  Topic 

aoriju
Posting Yak Master

156 Posts

Posted - 2011-03-14 : 08:30:30
I have a select statement 00001 + 1

I want to remove Prefix zero value

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-03-14 : 08:38:44
You could just convert it. SELECT convert(int,'00001') + 1

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-03-14 : 11:22:57
select 00001 + 1 returns 2

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

GhantaBro
Posting Yak Master

215 Posts

Posted - 2011-03-14 : 14:16:37
quote:
Originally posted by aoriju

I have a select statement 00001 + 1

I want to remove Prefix zero value



SELECT cast(convert(int,'00001') as varchar) + ' + 1'

Use substring and charindex if ur dealing with a column that has this value and has 000 as prefixes. You can use replace if u have 0s only as prefix.
Go to Top of Page
   

- Advertisement -