如题,找到一些资料谈到用@@error,但是不知道怎么写...
或者sqlca不知道这两种方面都怎么用,我现在用的sql server2005数据库系统,还有一个问题,那个出错代号数据库表在sqlserver2005叫什么...

解决方案 »

  1.   

    @@ROWCOUNT > 0 and @@ERROR = 0
      

  2.   

    ---例子---
    USE pubs
    GO-- Create the procedure.
    CREATE PROCEDURE add_author 
    @au_id varchar(11),@au_lname varchar(40),
    @au_fname varchar(20),@phone char(12),
    @address varchar(40) = NULL,@city varchar(20) = NULL,
    @state char(2) = NULL,@zip char(5) = NULL,
    @contract bit = NULL
    AS-- Execute the INSERT statement.
    INSERT INTO authors
    (au_id,  au_lname, au_fname, phone, address, 
     city, state, zip, contract) values
    (@au_id,@au_lname,@au_fname,@phone,@address,
     @city,@state,@zip,@contract)--@error等于零代表没有错误,不等于零代表插入错误
    IF @@ERROR <> 0 
    BEGIN
       -- Return 99 to the calling program to indicate failure.
       PRINT "An error occurred loading the new author information"
       RETURN(99)
    END
    ELSE
    BEGIN
       -- Return 0 to the calling program to indicate success.
       PRINT "The new author information has been loaded"
       RETURN(0)
    END
    GO
      

  3.   

    各位高手,但是试用来没有反映...
    @@error要declare @error int
    这样定义吗
      

  4.   

    不用定义
    @@rowcount和@@error是全局变量
      

  5.   

    @@error要declare @error int
    这样定义吗----------
    不用,这是系统自带的全局变量