July 31, 2009 at 11:06 pm
hi,
I have string like this : 010809001
the '001' is increased every time.
i want to get that incremented value.
please help me
Thanks
Dastagiri.D
July 31, 2009 at 11:54 pm
Hi,
this is constant of the 3 digit from right then
try this
declare @result varchar(15)
set @result = '20090801001'
select right(@result,3)
August 1, 2009 at 1:43 am
hi..
Its not a constant number .it increased.
Thanks
Dastagiri.D
August 1, 2009 at 2:23 am
Hi, then try this
declare @result varchar(15)
set @result = '200908010011'
select replace(@result,left(@result,8)/*Your fixed left char*/,'')
August 1, 2009 at 6:34 am
Some other options if you have from 1-X characters following the year/month/date:
declare @samples table (result varchar(15))
insert into @samples
select '2009080105' union all
select '20090801099' union all
select '200908010111' union all
select '2010010102'
select right(result,len(result)-8) as [right()]from @samples
select stuff(result,1,8,'') as [stuff()] from @samples
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply