update ...if @@rowcount<>0
    insert ...

解决方案 »

  1.   

    update ...if @@rowcount<>0
        insert ...
      

  2.   

    update table1 set columnD='grape' where columnD=' ' 
    --select @@rowcount
    if @@rowcount=0 
      ....
    else
      insert
      

  3.   

    IF @@ROWCOUNT = 0
    insert into 表(字段列表) values(值 列表)
    两行搞定
      

  4.   

    example:
    ------------------------------------------------
    create table #t (ID int,Name varchar(20))
    insert into #t select 1,'AAAA'
    insert into #t select 2,'BBBB'
    insert into #t select 3,'CCCC'
    insert into #t select 4,'DDDD'
    insert into #t select 5,'EEEE'
    insert into #t select 6,'FFFF'
    GO
    update #t set Name = 'GGGG' where ID = 7if @@rowcount<>0
        insert into #t select 7,'GGGG'
    select * from #t--输出结果
    ID   Name
    ---  ----
    1    AAAA
    2    BBBB
    3    CCCC
    4    DDDD
    5    EEEE
    6    FFFF
    7    GGGG
      

  5.   

    update ...
    if @@ERROR=0
       if @@rowcount=0
          insert ...