Link to home
Start Free TrialLog in
Avatar of robthomas09
robthomas09

asked on

SQL - substring query assistance

Hi experts,

I am trying to write a query that replaces the very first instance of the word 'Cath' in a string, with the word 'Echo'.

So far I have:

  update  card_proceduresextpop_
set reportdisplay =  REPLACE(SUBSTRING(reportdisplay, 1, CHARINDEX(reportdisplay,'Echo',1)), 'Echo', 'Cath')
         , SUBSTRING(reportdisplay, CHARINDEX(reportdisplay,'Echo',1)+1, LEN(reportdisplay))
  FROM card_proceduresextpop_
  where procedureabbr = 'Echo'
and substring(reportdisplay, 1, 4) = 'Echo'

but it gives me an error:

Msg 102, Level 15, State 1, Line 5
Incorrect syntax near ','.


Any ideas?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of robthomas09
robthomas09

ASKER

Thanks!