Home Forums SQL Server 2008 T-SQL (SS2K8) how to use substring and charindex to extract desired string RE: how to use substring and charindex to extract desired string

  • This ?

    DECLARE @STR VARCHAR(40)='ek/df/cv/'

    DECLARE @strreverse VARCHAR(40)=Reverse(@str)

    SELECT Substring(@strreverse, 1, Charindex('/', @strreverse) - 1)

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server