HoustonGuy
Programmer
I have multiple fields to update based on a single field's condition.
I can't find the proper format.
Update Table1
Set Field1 = CASE when Field85 <> '' then isnull(A.Field2, ''),
Field2 = isnull(A.Field3, ''),
Field3 = isnull(A.Field4, '')
else
Field1 = isnull(A.Field1, ''),
Field2 = isnull(A.Field2, ''),
Field3 = isnull(A.Field3, '')end
from #TempTable A
Join table1 B
on A.IDnumber = B.IDnumber
Based on the contents of field I need to determine the updates on a lot of fields.
Is it possible to use a case to do multiple updates in a single statement?
I hope my example is clear enough - if not I'll clarify.
Thank you to my brothers and sisters in advance!
I can't find the proper format.
Update Table1
Set Field1 = CASE when Field85 <> '' then isnull(A.Field2, ''),
Field2 = isnull(A.Field3, ''),
Field3 = isnull(A.Field4, '')
else
Field1 = isnull(A.Field1, ''),
Field2 = isnull(A.Field2, ''),
Field3 = isnull(A.Field3, '')end
from #TempTable A
Join table1 B
on A.IDnumber = B.IDnumber
Based on the contents of field I need to determine the updates on a lot of fields.
Is it possible to use a case to do multiple updates in a single statement?
I hope my example is clear enough - if not I'll clarify.
Thank you to my brothers and sisters in advance!