易截截图软件、单文件、免安装、纯绿色、仅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'。
*/


相关问答:

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

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

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

MS SQL作业问题 - MS-SQL Server / 应用实例

如何在SQL2005中设定定时作业,比如说定时清理某些表的数据,
或者是定时的将某些表的数据导出excel!
在线等待,急急急,最好是详细步骤!
之前我做的作业有点问题!
帮UP

参考:http://hi.baidu.com/toiota ......

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

我想查询出每天数据的最大的一个值。表的格式如下
表名: hisdata
字段 编号 值 状态 时间  
  Id value state dattime  
  101 32.3 0 ......

关于Vb中sql语句的写法(100分) - Java / Web 开发

求个vb中的sql语句的写法,次sql语句的用法是分页程序
我写的如下:其中A是用来接收每页显示的记录的条数,B是用来接收显示的当前的页面.
sqltext="select top A * from log where id not in(select top ( ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号