Conditional update field in sql

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to update a field conditionally in sql. For example: if file.error =
"A" set file.description = "Error A" else set file.description = "Unknown".
Is there a way to do this with one sql statement?
 
Stukmeister said:
I need to update a field conditionally in sql. For example: if file.error =
"A" set file.description = "Error A" else set file.description = "Unknown".
Is there a way to do this with one sql statement?

SET file.description = Iif(file.error="A","Error A","Unknown")
 
UPDATE YourTable
SET [Description] = IIf([error] = "A", "Error A", "Unknown")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top