Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
balamuruganmca
Starting Member
1 Post |
Posted - 2012-10-24 : 20:38:57
|
| dear sir,i have a problem on updating statement.problem is i have a table named is DEPARTMENT and now i have added new column named QUALITY having 5 rows in which how can i update following item 'goood''bad''fine''nice' at a time using single update instead using a update statament again and againbalamurugan |
|
|
chadmat
The Chadinator
1974 Posts |
Posted - 2012-10-24 : 22:42:37
|
| Use a case statement? I don't think your objective is clear.-Chad |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-10-25 : 00:02:11
|
quote: Originally posted by balamuruganmca dear sir,i have a problem on updating statement.problem is i have a table named is DEPARTMENT and now i have added new column named QUALITY having 5 rows in which how can i update following item 'goood''bad''fine''nice' at a time using single update instead using a update statament again and againbalamurugan
whats the rule for determining which value goes for which department?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2012-10-25 : 01:09:20
|
| For suppose there are departments 10,20,30,40,50.Assume that10,20 departments are good,30 -------> bad40 -------> fine50 -------> niceTo update department table for above requirement, you have write query as follows:UPDATE Department SET Quality = CASE WHEN departmneid IN (10,20) THEN 'good' WHEN departmneid = 30 THEN 'bad' WHEN departmneid = 40 THEN 'fine' WHEN departmneid = 50 THEN 'nice' end --Chandu |
 |
|
|
|
|
|