create table #aa ()
insert into #aa
exec #p
if @@error <> 0 
select 1
这样应该可以吧?

解决方案 »

  1.   

    if not object_id('tempdb..#p') is null drop proc #pgocreate proc #p as
    raiserror 20009 '错误,原因是ABC'
    return -1
    goSet XACT_ABORT  on 
    exec #p
    if @@error <> 0 
    raiserror 20010 '执行#p错误,错误信息是:' --这里,怎样得到"错误,原因是ABC"感觉兄的不行。
      

  2.   

    我看了一个帮助,帮助上的raiserror有通过全局变量来传的
      

  3.   

    if not object_id('tempdb..#p') is null drop proc #pgocreate proc #p as
    raiserror (50009, 16, 2)
    return -1
    goSet XACT_ABORT  on 
    exec sp_dropmessage 50009
    exec sp_addmessage @msgnum = 50009, @severity = 16, @msgtext = N'错误,原因是ABC'
    exec #p
    if @@error <> 0 
    select 1
    raiserror (50009, 16, 2)
      

  4.   

    我把现在的情况跟大家说一下,大家想想办法。我现在有好几个存储过程,每个过程里有好多raiserror语句。我想建一个新存储过程,逐一调用那些存储过程,并且当那些存储过程出错时,将出错的信息存到一个表中。所以,我想如果能在不改动已有的存储过程的基础上实现这个功能。
      

  5.   

    自己做一个raiserror过程,报错,兼保存
    替换所有raiserror
    要改原有过程
    但只是全部替换
    应该很方便
      

  6.   

    生成SQL脚本
    拿UE一次性替换
    不用五分钟