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 |
|
kirknew2SQL
Posting Yak Master
194 Posts |
Posted - 2008-01-16 : 22:06:28
|
| I have a table in which I need to populate one column with a value from one of the other columns. As soon as a value ios found the remaining columns don't need to be evaluated.What is the correct syntax for this IF? Or is there a better way to do this?UPDATE MyTable SET FillPhone = If !ISEMPTY(FillPhone) Phone If !ISEMPTY(FillPhone) NewSo_Phone IF !ISEMPTY(FillPhone) MediC_Phone IF !ISEMPTY(FillPhone) Insur_Phone thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-01-16 : 22:14:54
|
[code]UPDATE MyTableSET FillPhone = coalesce(FillPhone, Phone, NewSo_Phone, MediC_Phone, Insur_Phone)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
kirknew2SQL
Posting Yak Master
194 Posts |
Posted - 2008-01-16 : 22:25:12
|
| Had to go look that one up. :) I haqd never heard of that function. Thank you |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
kirknew2SQL
Posting Yak Master
194 Posts |
Posted - 2008-01-17 : 11:16:36
|
| Thanks for the URL. I learn something new every day. |
 |
|
|
|
|
|