Get everything after and before certain character in SQL Server

前端 未结 15 1910
臣服心动
臣服心动 2020-12-07 18:48

I got the following entry in my database:

images/test.jpg

I want to trim the entry so I get: test

So basically, I want

15条回答
  •  时光取名叫无心
    2020-12-07 19:08

    Simply Try With LEFT ,RIGHT ,CHARINDEX

    select 
    LEFT((RIGHT(a.name,((CHARINDEX('/', name))+1))),((CHARINDEX('.', (RIGHT(a.name, 
                         ((CHARINDEX('/', name))+1)))))-1)) splitstring,
    a.name      
    from 
       (select 'images/test.jpg' as name)a
    

提交回复
热议问题