SQLTeam.com | Weblogs | Forums

Can I use case statements in my update query


#1

Basically instead of running to seperate queries, can I combine into one using case statement?

  1. Update Steps Set Completed = 1 Where NameID IN (5,6)

And

Update Steps Set Completed = 0 Where NameID NOT IN (5,6)


#2

Yes... Something like:

Update Steps
Set Completed = (case when NameID IN (5,6) then 1 else 0 end)