A B C D E F
  1 2 3   4 5
  1 2 3   4 5
  1 2 3   4 5
  1 2 3   4 5
这是我现在的查询结果我用的是c#winform的datagridview控件其中数据库中D列还没有存放数据 我想把查询结果显示成这样的
 A B C  D    E   F
  1 2 3  null 4  5 
  1 2 3  null 4  5
  1 2 3  null 4  5
  1 2 3  null 4  5请问该怎么去写呢

解决方案 »

  1.   

    select isnull(d,'空') from table1
      

  2.   

    d的数据类型是real 如过要是你那样写会报错的,有没有办法有代码去控制阿 
      

  3.   

    直接在 SQL 里面替换select a,b,c,d=CASE WHEN d is null THEN 'NULL' ELSE d END,e,f from table
      

  4.   

    在sql中处理啊,尽量少麻烦服务器吗
    对不对
    create table haha
    (
    a int,
    b int,
    c int,
    d int,
    e int
    )
    goinsert into haha(a,b,c,e) values(2,3,4,4)
    insert into haha(a,b,c,e) values(2,3,4,4)
    insert into haha(a,b,c,e) values(2,3,4,4)
    go
    select a,b,c,d=case
    when d is null then 'null' end,e from haha
    go
      

  5.   

    还是那个错误阿   将数据类型 varchar 转换为 real 时出错。还是不行阿
      

  6.   

    select isnull(convert(varchar(100),ff),'空') from table1
    转换下好了,其实用VARCHAR就可以了啊?你的精度要求很高吗?
      

  7.   

     我也知道在数据了解决最好阿 可是不行阿 我d列数据类型是real 这个库不是我建的,我没办法阿
      

  8.   

    select isnull(convert(varchar(100),ff),'空') from table1
    转换下好了,不过直接用VARCHAR也可以啊!你的精度要求很高吗?
      

  9.   

    select isnull(ff,convert(real(1000),'0.00')) from table1
    那这样吧
      

  10.   

    就不要显示成NULL了,就显示为0好了!
      

  11.   

    好象不用转换的哦!直接select isnull(ff,'0') from table1 就可以了