SQL表以1900-01-01为日期

时间:2018-05-24 22:17:24

标签: sql sql-server

我创建了一个日期时间选项,我试图在值为空或空白时在sql表中输入它,它以1900-01-01的形式进入表格。有没有办法创建一个sql语句来使此值为NULL而不是0?

do{
     //Tell the collection which page to load.
     $collection->setCurPage($currentPage);
     $collection->load();
     $fp = fopen(Mage::getBaseDir('export') .'/customers.json', 'a');
     foreach ($collection as $customer){
        //write collection as json
        fwrite($fp, "," . json_encode($customer->getData()));
        $customerCount++;
     }
     fclose($fp);
     $currentPage++;
     //make the collection unload the data in memory so it will pick up the next page when load() is called.
     $collection->clear();
     echo memory_get_usage() . "\n";
     echo "Finished page $currentPage of $pages \n"; 
} while ($currentPage <= $pages);

我之前正在阅读案例陈述我不知道这是否是正确的方向,如果这是我开始的地方。

var url = "@Url.Action("Create", "Categorias")";

1 个答案:

答案 0 :(得分:0)

试试这个NULLIF SQL2008 +

UPDATE animals_table
 SET
   animalname = 'Mary'
   ,animaltype = 'Husky'
 WHERE
   animalid = '123456'
 and  ISNULL(NULLIF(dategiven,'1900-01-01'),'') = ''

 UPDATE animals_table
 SET
   animalname = 'Mary'
   ,animaltype = 'Husky'
 WHERE
   animalid = '123456'
 and  NULLIF(dategiven,'1900-01-01') IS NULL