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 |
LOOKUP_BI
Constraint Violating Yak Guru
295 Posts |
Posted - 2011-04-20 : 17:04:41
|
Is there a way to replace NULL to a datetime column instead of 1900-01-01 00:00:00.000 for NULL dates ? |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-04-20 : 17:30:26
|
I'm not clear what you mean. Here's 2 solutions based on my poor interpretation:SELECT NULLIF(DateCol, 0) FROM myTable -- if DateCol = 1/1/1900, replace it with NULLSELECT IsNull(DateCol, '1/1/1900') FROM myTable -- if DateCol IS NULL, replace it with 1/1/1900 |
 |
|
LOOKUP_BI
Constraint Violating Yak Guru
295 Posts |
Posted - 2011-04-20 : 17:37:43
|
Robvolk,you interpreted me correct, let me try this |
 |
|
LOOKUP_BI
Constraint Violating Yak Guru
295 Posts |
Posted - 2011-04-21 : 14:12:20
|
NULLIF worked perfectly for me. Thanks |
 |
|
|
|
|