By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table test(code_c varchar(100))
insert into test values('510325205/000/01');
1 rows affected
insert into test values('510325205');
1 rows affected
select case when charindex('/',code_c)-1 = -1
then
code_c
else
left(code_c,charindex('/',code_c)-1)
end RESULT
from test
RESULT |
---|
510325205 |
510325205 |