Sunday, January 11, 2009

Update Table value with case in Sql

Use case for update the table value using sql query
Ex. table Gender_tbl and like this
id Gen_Name
1 Male
2 Male
3 Female
4 Femal
5 Male
no I have to update Gen_Name Male with M and Femal with F
solution:
UPDATE GENDER_TBL SET Gen_Name= (CASE WHEN (Gen_Name='Male') THEN 'M' WHEN (Gen_Name='Female') THEN 'F' else ' ' end)


Posted by Dilip Kumar

1 comment:

varun said...

Really Helpful..Keep it up!!