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 |
|
reddymade
Posting Yak Master
165 Posts |
Posted - 2008-07-11 : 10:09:02
|
| I want to fill data to a column(SpanishLabel) from the same tables another field called englishlabel, the condition is if the spanishlabel = NULL then fill the englishlabel columns data to it.Update Tab_ccsnetLabels set Spanishlabel= t2.englishlabel from tab_ccsnetlabels t1 inner join tab_ccsnetlabels t2on t1.labelkey = t2.labelkey and t1.spanishlabel = NULLThank you very much for the helpful information. |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2008-07-11 : 10:20:03
|
| where's the question?UPDATE Tab_ccsnetLabels SET Spanishlabel = COALESCE(Spanishlabel, englishlabel) |
 |
|
|
reddymade
Posting Yak Master
165 Posts |
Posted - 2008-07-11 : 10:21:47
|
Thanks,But i don't see the condition for where spanishlabel=NULLquote: Originally posted by rohitkumar where's the question?UPDATE Tab_ccsnetLabels SET Spanishlabel = COALESCE(Spanishlabel, englishlabel)
|
 |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2008-07-11 : 10:46:23
|
| read thishttp://msdn.microsoft.com/en-us/library/ms190349.aspx |
 |
|
|
bjoerns
Posting Yak Master
154 Posts |
Posted - 2008-07-11 : 12:02:00
|
| NULL never equals anything!Update Tab_ccsnetLabels set Spanishlabel= t2.englishlabel from tab_ccsnetlabels t1 inner join tab_ccsnetlabels t2on t1.labelkey = t2.labelkey and t1.spanishlabel IS NULL |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-12 : 00:58:11
|
quote: Originally posted by bjoerns NULL never equals anything!Update Tab_ccsnetLabels set Spanishlabel= t2.englishlabel from tab_ccsnetlabels t1 inner join tab_ccsnetlabels t2on t1.labelkey = t2.labelkey and t1.spanishlabel IS NULL
No need of the join.just use COALESCE as suggested by Rohit. |
 |
|
|
|
|
|