表A有三列a,b,c,我想当插入或者修改时,能够知道这一行a列的数据,并统计相同行有多少行

解决方案 »

  1.   

    --这个意思?
    create table tb(a int,b int,c int)
    insert into tb select 1,2,3
    insert into tb select 4,4,5
    insert into tb select 6,7,8
    gocreate trigger cfq on tb
    for insert,update
    asif @@rowcount=0 returnif exists(select 1 from sysobjects where id=object_id('ta') and xtype='u')
    drop table taselect a.a,(select count(*) from tb where a=a.a) as 行数 into ta from inserted a group by a.a
    goinsert into tb select 1,2,3
    select * from tb
    select * from ta
    goupdate tb set a=3 where a=1
    select * from tb
    select * from ta
    godrop trigger cfq
    drop table tb,ta
      

  2.   

    大哥是这个意思,可能我没说明白,我想当表A插入或者修改一行数据时,能够知道这插入或者修改的这一行a列的数据的值,并统计这个表中a列都等于当前行a列数据值的相同行有多少行