Table A:
Id Name DateCreated DateModified
-----------------------------------
1 A 2013-1-12 2013-1-15
2 B NULL 2013-2-1
3 C NULL NULL
I have to migrate this table's data to another table in which DateCreated
is a not nullable column, and the conditions are if DateCreated
is null use DateModified
and if both are null use current date.
I can't use
ISNull(DateCreated,DateModified)
because both can be null.
How do I do it? The table has around 10000 rows.
You can use COALESCE(DateCreated, DateModified, GETDATE())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With