Monday, October 3, 2011

Update statement using Case

Update statement using case in SQL.
 where the city is 'Agra Cantt' Update it to Agra
and where it is New Delhi update It to Delhi



Update dbo.TableEmployee
Set TableEmployee.City= Case 
  When TableEmployee.City='New Delhi' then 'Delhi'
  When TableEmployee.City='Agra Cantt' then 'Agra'
End

1 comment:

  1. Good 1
    Its a basic Query but very useful sometimes and is asked in most of the 0-1yr interview

    ReplyDelete