Trimming number by even location in a row

I would like to find a way to trim a set of numbers by even location in a row. For example: 36303032363038333031. The output should be like 6002608301

Cast as character then pull what you need. Cast the result back to the number format you wish.

1 Like

I will try that, thanks

Hi djj55,

Thanks for your reply.

I'm a beginner in this.

Could you kindly provide an example.

I will try to grasp from there.

Thanking you in advance.

What is the criteria for the trim?

1 Like
declare    
    @str    varchar(20) = '36303032363038333031',
    @p    int,
    @o    varchar(20)

select    
    @p    = len(@str),
    @o    = ''
while    @p    >= 1
begin
    select    @o = substring(@str, @p, 1) + @o
    select    @p = @p - 2
end
select    @o