declare @Find varchar(20)
declare @search varchar(50)
SET @Find=’- ‘
SET @Search=’hhhjoehhh-joehhhjoex- 02340’
SELECT COALESCE(RIGHT(@search, NullIf(CHARINDEX(REVERSE(@Find), REVERSE(@search)), 0)-1), @search)
sql for everyone
declare @Find varchar(20)
declare @search varchar(50)
SET @Find=’- ‘
SET @Search=’hhhjoehhh-joehhhjoex- 02340’
SELECT COALESCE(RIGHT(@search, NullIf(CHARINDEX(REVERSE(@Find), REVERSE(@search)), 0)-1), @search)