欢迎投稿

今日深度:

必须会的SQL语句(五) NULL数据处理和类型转换,

必须会的SQL语句(五) NULL数据处理和类型转换,null数据处理


1.Null数据的处理

    1)检索出null值
              select * from 表 where xx is null
  
    2)null值替换
     select
         name,
         isnull ( cast (字段 as varchar(20)) , '空')
     from 表名
 
2.数据类型转换
    1)Cast
        --'101'可以用表中字段来替换
        select cast('101' as varchar(20))
  
    2)Convert
        select convert(varchar(20),100)

www.htsjk.Com true http://www.htsjk.com/Sql_Server/11677.html NewsArticle 必须会的SQL语句(五) NULL数据处理和类型转换,null数据处理 1.Null数据的处理 1)检索出null值 select * from 表 where xx is null 2)null值替换 select name, isnull ( cast (字段 as varchar(20)) , '空') from...
评论暂时关闭