摘要: 关于Exec返回值的问题有很多,在这做个简要的总结。 读查询语句示例: Declare @count int1set@strSql=N'select@a=count(*)from['+@tblName+']where1=1'+@strWhere2execsp_executesql@strSql,N'@aintoutput',@Countoutput3select@Count 要点:1.利用系统存储过程 sp_executesql 2. 在要执行的Sql文中加入参数,如 "@a",在sp_executesql的参数声明中要指定参 阅读全文
posted @ 2014-03-23 22:20 大院 阅读(380) 评论(0) 推荐(0) 编辑
摘要: 事务处理是在数据处理时经常遇到的问题,经常用到的方法有以下三种总结整理如下:方法1:直接写入到sql 中在存储过程中使用 BEGIN TRANS, COMMIT TRANS, ROLLBACK TRANS 实现begin transdeclare @orderDetailsError int,@procuntError intdelete from [order details] where productid=42select @orderDetailsError =@@errordelete from products where productid=42select @procuntEr 阅读全文
posted @ 2014-03-23 22:17 大院 阅读(199) 评论(0) 推荐(0) 编辑