How to use NULL or empty string in SQL

前端 未结 16 1461
悲&欢浪女
悲&欢浪女 2020-12-23 20:20

I would like to know how to use NULL and an empty string at the same time in a WHERE clause in SQL Server. I need to find records that have either null values o

相关标签:
16条回答
  • 2020-12-23 20:48

    youe check null With IS NULL and string Empty With LEN(RTRIM(LTRIM(Column))) = 0 in

    SELECT *
    FROM AppInfra.Person
    WHERE   LEN(RTRIM(LTRIM(NationalCode))) = 0 OR  NationalCode IS NULL
    
    0 讨论(0)
  • 2020-12-23 20:49

    You can simply do this:

    SELECT *
    FROM   yourTable
    WHERE  yourColumn IS NULL OR yourColumn = ''
    
    0 讨论(0)
  • 2020-12-23 20:49
    SELECT *
    FROM   TableName
    WHERE  columnNAme IS NULL OR 
           LTRIM(RTRIM(columnName)) = ''
    
    0 讨论(0)
  • 2020-12-23 20:53
    select 
       isnull(column,'') column, * 
    from Table  
    Where column = ''
    
    0 讨论(0)
提交回复
热议问题