Chewdoggie
Chewdoggie

Reputation: 449

Can't get update statement in SQL Server to work

I'm attempting to execute this SQL Update statement and it's not working. Does anyone know why ?

update dbo.EBSTable 
set CommandField = replace(CommandField, '%APPL.mbm_aging_file', '%APPL.mbm_aging_file)') 
where Command like '[%]APPL.mbm_aging_file'

Basically, I'm just trying to add a ")" to the end of the data appearing in the CommandField field where the value is %APPL.mbm_aging_file (The "%" actually appears in the data).

Upvotes: 0

Views: 53

Answers (2)

Vamsi Prabhala
Vamsi Prabhala

Reputation: 49260

update dbo.EBSTable 
set CommandField = '%APPL.mbm_aging_file' + ')' -- or set CommandField = '%APPL.mbm_aging_file)'
where Command = '%APPL.mbm_aging_file'

You can do this, as you only need to add ) at the end only for this specific case.

Upvotes: 1

Chewdoggie
Chewdoggie

Reputation: 449

I discovered my where clause was inadequate (like me with SQL). It should read

update dbo.EBSTable set CommandField = replace(CommandField, '%APPL.mbm_aging_file', '%APPL.mbm_aging_file)') where Command like '%[%]APPL.mbm_aging_file%'

That statement worked.

Upvotes: 1

Related Questions