SQL - Convert Select statment to Update

I need this to be an update statement but I am having problems with the syntax.

Any help is appreciated.

SELECT staffID, staffLUServiceID, staffOtherLUServiceIDs,
	   substring(replace(','+staffOtherLUServiceIDs+',',@oldCode,@newCode),2,(len(staffOtherLUServiceIDs)+ @modLength)) as Fixed_staffOtherLUServiceIDs
FROM LUHospitalStaff
WHERE ISNULL(staffOtherLUServiceIDs,'') != ''
AND ','+staffOtherLUServiceIDs+',' LIKE '%,'+@oldCode+',%'

Open in new window

JohnMac328Asked:
Who is Participating?
 
Pawan KumarConnect With a Mentor Database ExpertCommented:
Please use this -

Assuming staffOtherLUServiceIDs  column to be updated.

--

Update LUHospitalStaff
SET staffOtherLUServiceIDs = substring(replace(','+staffOtherLUServiceIDs+',',@oldCode,@newCode),2,(len(staffOtherLUServiceIDs)+ @modLength)) 
WHERE ISNULL(staffOtherLUServiceIDs,'') != ''
AND ','+staffOtherLUServiceIDs+',' LIKE '%,'+@oldCode+',%'

--

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.