Get everything after and before certain character in SQL Server

前端 未结 15 1945
臣服心动
臣服心动 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:21

    ----select characters before / including /

    select SUBSTRING ('abcde/wxyz',0,CHARINDEX('/','abcde/wxyz')+1)
    

    --select characters after / including /

    select SUBSTRING('abcde/wxyz',CHARINDEX('/','abcde/wxyz'),LEN('abcde/wxyz')) 
    

提交回复
热议问题