sql2005 若字段定義的類型為datetime,插入為''(空),那麼會默認值為1900-01-01 00:00:00.000
解決方法查詢的時候過濾下cast(nullif('','') as datetime)
復制代碼 代碼如下:
select cast('' as datetime)
, cast(nullif('','') as datetime)
, isnull(cast(nullif('','') as datetime),getdate())
/*
----------------------- ----------------------- -----------------------
1900-01-01 00:00:00.000 NULL 2009-02-25 17:18:15.140
(1 行受影響)
*/