易截截图软件、单文件、免安装、纯绿色、仅160KB

mssql存储过程中容错处理 - MS-SQL Server / 基础类

exec YYys 'aa' aa是mssql非正确的语句,
里面是通过 exec (@sql)--上面aa所传递的参数就是@sql调用的,如果如何让exec @sql出错后存储过程能输出错误。
这个?

貌似很难,类似人为错误只能从行政方面入手.

没理解lz的目的


SQL code:
declare @msg nvarchar(4000)
declare @severity int

IF @@ERROR <> 0
BEGIN
select @msg=description,@severity=severity from sysmessages where msglangid = 2052 and error=@@ERROR
--print @msg
RAISERROR (@msg, @severity, 1)

END


SQL code:

declare @msg nvarchar(4000)
declare @severity int
exec('aa')
IF @@ERROR <> 0
BEGIN
select @msg=description,@severity=severity from sysmessages where msglangid = 2052 and error=@@ERROR
--print @msg
RAISERROR (@msg, @severity, 1)

END
/*
服务器: 消息 2812,级别 16,状态 62,行 1
找不到存储过程 'aa'。
*/


引用
SQL code

declare @msg nvarchar(4000)
declare @severity int
exec('aa')
IF @@ERROR <> 0
BEGIN
select @msg=description,@severity=severity from sysmessages where msglangid = 2052 and error=@@……

/*
服务器: 消息 2812,级别 16,状态 62,行 1
找不到存储过程 'aa'。
*/


相关问答:

SQL如何优化问题 - MS-SQL Server / 疑难问题

今天做了一个存储过程   环境是SQL2000数据库  
大致如下
建立临时表
定义员工游标
        循环员工(属于1个公司)  
        ......

数据以xml格式返回 - MS-SQL Server / 应用实例

从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式
XML code:
<folder state="unchecked" label="全部">
   <folder state="unchecked&qu ......

sqlserver错误 - MS-SQL Server / 疑难问题

sqlserver2005 建立的数据库,与手持pda传输数据,最近突然出现无法传递数据的问题,pda端提示的错误时outofmemoryexception,但是pda上面的容量没有问题,
sqlserver的日子上的错误如下:
日期 2010-1-25 14:45: ......

求一SQL - MS-SQL Server / 基础类

tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......

请教SQL语句查询问题? - MS-SQL Server / 基础类

我想查询出每天数据的最大的一个值。表的格式如下
表名: hisdata
字段 编号 值 状态 时间  
  Id value state dattime  
  101 32.3 0 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号