你的第三个变量是int类型的,你怎么付的值为'a',这样当然不可以

解决方案 »

  1.   

    好的,
    象上面说的,我新增记录,由于tbl_test的第三个字段时条件不满足,所以会报错,我就是想知道那个字段的列名,然后返回给用户,让他修改这个字段的内容,然后重新调用 sp_test新增数据
      

  2.   

    -- 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 = NULLAS  -- 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)  -- Test the error value.IF @@ERROR <> 0 BEGIN   -- Return 99 to the calling program to indicate failure.   PRINT "An error occurred loading the new author information"   RETURN(99)ENDELSEBEGIN   -- Return 0 to the calling program to indicate success.   PRINT "The new author information has been loaded"   RETURN(0)END
      

  3.   

    create procedure sp_test
      @a1 varchar(10),
      @a2 varchar(10),---
      @a3 int
    as 
      exec('insert into tbl_test values('+@a1+','+@a2+','+@a3+')')sp_test 'aaaa','a',5
      

  4.   

    以上都没有用,错误信息号@@error,对应的错误信息(可查sysmessaegs表),
    我都可以知道啊,但我想得到的是插入记录时,哪一列(???????)(或字段)引起的错误,以至于insert失败。
      

  5.   

    除非对字段做触发器,否则没办法
    @@ERROR只能判断上一句的执行情况