由于需要
create view vw_a as 
select 
A_ID,
ISNULL([count],0) AS count
from A这样会报错 有什么解决的方法?

解决方案 »

  1.   

    create view vw_a as 
    select 
    A_ID, 0 AS [count] 
    from A 
      

  2.   

    如果[count]是表A里的字段,那么把as count 的 count 也加上 []
      

  3.   

    create view vw_a(A_ID,count) as 
    select 
    A_ID, 
    ISNULL([count],0) AS count 
    from A 
      

  4.   

    --测试:create table tb(id int,[count] int)insert into tb select 1,1create view v_test  (id,[count])
    as
    select id,isnull([count],0) [count] from tbselect * from v_test/*
     id  count
    ------------
      1    1
    */drop view v_test
    drop table tb
      

  5.   

    create view vw_a as 
    select 
    A_ID, 
    ISNULL([count],0) AS [count] 
    from A 
      

  6.   

    还没解决了
    Msg 207, Level 16, State 1, Procedure vw_a, Line 4
    Invalid column name 'count'.
    count不是表的字段 是我要在View里面建的
      

  7.   

    因为编译通不过.
    楼主是不是要获取该表的纪录数,然后返回一个名为COUNT的列?如果是,那就create view vw_a as 
    select 
    A_ID, 
    isnull(count(*),0) as [count]
    from A 
    group by A_ID
      

  8.   


    create view vw_a as 
    select 
    A_ID, 
    ISNULL([count],0) AS [count]  --count 字段别名与关键字冲突了,需要加[]
    from A 
      

  9.   


    就是要在view里面多个字段
    不是要统计
    create view vw_A as
    select
    A_ID,
    ISNULL([count],0) AS [count]
    from A这样还是不行的
    Msg 207, Level 16, State 1, Procedure vw_A, Line 4
    Invalid column name 'count'.