如何获取sp_executesql的返回码? [英] How to get the return code of sp_executesql?

查看:88
本文介绍了如何获取sp_executesql的返回码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MSDN说sp_executesql在成功时返回代码值0,在失败时返回任何其他非零值。我如何在变量中捕获它?一个简单的例子请。



另外,它可以按照我描述的方式在MSSQL 2005中获得吗?



问候!

解决方案

 声明  @ ret   as 整数; 
exec @ ret = sp_executesql .......;


MSDN says sp_executesql returns code values 0 on success and any other non-zero value on failure. How do I catch it in a variable? A simple example please.

Also, can it be gotten in MSSQL 2005 just the way I described?

Regards!

解决方案

declare @ret as integer;
exec @ret = sp_executesql .......;


这篇关于如何获取sp_executesql的返回码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆