怎样用一条sql语句并返回 成功,或者失败

解决方案 »

  1.   

    if exists (select 1 from syscolumns where id=object_id('表名') and name=@name)
      pring '成功'
    else 
      pring '失败'
      

  2.   

    if not exists(select 1 from tb where id=100) insert into tb select 100,'aa','bb' 
    --如果同时还要返回信息,那要用存储过程
      

  3.   

    declare @name varchar(100) --字段名
    if exists (select 1 from syscolumns where id=object_id('表名') and name=@name)
      print '成功'
    else 
      print '失败'
      

  4.   


    --不过,如果这也能算是一条语句的话...
    if not exists(select 1 from tb where id=100) begin insert into tb select 100,'aa','bb'  select '成功' end else select '失败'
      

  5.   

    ACCESS和MSSQL差不多,你可以试试.
      

  6.   

    不行,期待delete 。。等 语句然后选定的是if