如题

解决方案 »

  1.   

    用 case ... then ... end
      

  2.   

    select 字段1,isnull(字段2,'没有内容') as 字段2 from tb
      

  3.   

    如:
    USE AdventureWorks;
    GO
    SELECT   ProductNumber, Category =
          CASE ProductLine
             WHEN 'R' THEN 'Road'
             WHEN 'M' THEN 'Mountain'
             WHEN 'T' THEN 'Touring'
             WHEN 'S' THEN 'Other sale items'
             ELSE 'Not for sale'
          END,
       Name
    FROM Production.Product
    ORDER BY ProductNumber;
    GO
      

  4.   

    也可以用 isnull(col,'没有内容') 
      

  5.   

    case when col='' then '没有内容' else col end
      

  6.   

    select 
      case when len(ltrim(rtrim(col)))=0 then '没有内容' else col end as col 
    from tb
      

  7.   

    select isnull(nullif([Field],''),'没有内容') from [Table]
      

  8.   

    select case when ritim(字段) is null then '没有内容' else 字段
    from tb 
      

  9.   


    SELECT ISNULL(字段,'没有内容') FROM TABLE
      

  10.   

    select case when colname='' then '没有内容' else colname end from tb
      

  11.   

    --> (让你望见影子的墙)生成测试数据,时间:2009-04-03
     
    if not object_id('tb') is null
    drop table tb
    Go
    Create table tb([id] int,[name] nvarchar(5),[password] nvarchar(5))
    Insert tb
    select 1,N'wang',N'wang' union all
    select 2,N'zhang',N'zhang' union all
    select 3,null,null
    Go
    Select * from tbselect id,name=case when ltrim(name) is null then '没有内容' else name end
    from tb 
      

  12.   

    刚进来还1楼呢,回完成九楼了!SQL版的效率让我震惊!
      

  13.   

    select isnull(字段,'没有内容') as 字段 from 表名
      

  14.   

    select isnull(字段,'没有内容') as 字段 from 表名