zoukankan      html  css  js  c++  java
  • 空值的日期类型和update 中的null

    创建一个表

    create table testdate1(name nvarchar(50),dtime datetime)
    go
    insert into testdate1 values('x11',''),('x12','1900-01-01 00:00:00.000')
    go
    select * from testdate1

    image

    select * from testdate1 
    where dtime=''

    image

    update testdate1 set dtime=null
    where name='x11'
    select * from testdate1
    where dtime is null

    image

    上面的测试,只是要说明两点

    1.datetime类型是空的话,会设置为datetime的初始值;select查询时where条件直接可以=’’。这条很容易理解的

    2.update语句中,null值也使用'=’;以前只知道where条件中的null,必须使用is null(当然SET ANSI_NULLS ON改为OFF就可以用‘=’,一般人不会闲着蛋疼加上这句,我刚刚蛋疼了一把),而不知道更新中可以使用‘=’设置null

  • 相关阅读:
    树莓派frp添加为服务管理
    liunx开源打印驱动foo2zjs编译小坑
    树莓派中实现ll命令
    Windows中使用QEMU创建树莓派虚拟机
    C#打印条码BarTender SDK打印之路和离开之路(web平凡之路)(转)
    数据库连接池问题 Max Pool Size
    C#时间
    XAF 如何从Excel复制多个单元格内容到GridView(收藏)
    C#日期处理(转) 太忘记了,备忘
    C#、devExpress 的 给bandedGrid加菜单功能 :复制、粘贴的例子(转)
  • 原文地址:https://www.cnblogs.com/cnmarkao/p/3835726.html
Copyright © 2011-2022 走看看