March 15, 2011 at 1:37 pm
I am needing to update a table. I was told the if exists() update procedure would for me however i am getting some errors when trying to update the table in a test environment. below is my syntax and the error(s) I am receiving.
if exist (
select m.MR,
en.Pat,
e.Exam,
--replace(p.nam, ' RT ', ' LT '),
p.nam,
e.lat,
e.ProID
from tbPro p
join tbEx e on p.ProcID = e.ProcID
join tbEn en on e.EncountID = en.EncountID
join tbMR m on en.pat = m.Pat
where p.name like ('% RT %')
and e.lat not in ('R','B')
)
update tbPro p
set p.nam= replace(p.nam, ' RT ', ' LT ')
where p.nam like ('% RT %')
and e.lat not in ('R','B')
This is the errors I receive.
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'select'.
Msg 170, Level 15, State 1, Line 15
Line 15: Incorrect syntax near ')'.
Any help would be greatly appreciated.
March 15, 2011 at 1:51 pm
IF EXISTS ...
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
March 15, 2011 at 1:57 pm
Thank you! Can't believe I missed that. :blush:
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply