代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
MSSQL
】
利用游标循环进行更新插入的SQL事务语句
作者:
Dezai.CN
/ 发布于
2012/11/6
/
852
<div><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">当两个或两以上的操作要么都执行,要么都执行时要用事务。</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; font-weight: bold; color: rgb(128, 0, 0);">1</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">.Sql写法(事物</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(128, 128, 128);">+</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">游标) <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">开始事务</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">BEGIN</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">TRAN</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">不显示计数信息</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">SET</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">NOCOUNT</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">ON</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">DECLARE</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 0);">@ProjNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; font-weight: bold;">varchar</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">(</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; font-weight: bold; color: rgb(128, 0, 0);">50</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">),</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 0);">@CusNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; font-weight: bold;">varchar</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">(</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; font-weight: bold; color: rgb(128, 0, 0);">50</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">) <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">声明游标</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">DECLARE</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">CRMPSContact_cursor</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">CURSOR</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">FOR</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">SELECT</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">ProjNo <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">FROM</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">CRMPSContact <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">WHERE</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">ProjNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(128, 128, 128);">></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; font-weight: bold; color: rgb(128, 0, 0);">0</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">打开游标</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">OPEN</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">CRMPSContact_cursor <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">取第一行的值给专案变量:@ProjNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">FETCH</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">NEXT</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">FROM</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">CRMPSContact_cursor <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">INTO</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 0);">@ProjNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">取得客户号</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">select</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 0);">@CusNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(128, 128, 128);">=</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">CusNo <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">from</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">CRMPSProjectM <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">where</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">ProjNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(128, 128, 128);">=</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 0);">@ProjNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">得到CRMPSContact中某专案号对应的客户号</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">update</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">CRMPSContact <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">set</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">CusNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(128, 128, 128);">=</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 0);">@CusNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">where</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">ProjNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(128, 128, 128);">=</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 0);">@ProjNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">执行错误回滚</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">if</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; font-weight: bold; color: rgb(0, 128, 0);">@@error</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(128, 128, 128);">!=</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; font-weight: bold; color: rgb(128, 0, 0);">0</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">begin</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">rollback</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">tran</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">return</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">end</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">移动游标,其它所有行更新操作(当到结尾时退出)</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">WHILE</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; font-weight: bold; color: rgb(0, 128, 0);">@@FETCH_STATUS</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(128, 128, 128);">=</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; font-weight: bold; color: rgb(128, 0, 0);">0</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">BEGIN</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">游标移到下一行</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">FETCH</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">NEXT</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">FROM</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">CRMPSContact_cursor <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">INTO</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 0);">@ProjNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">取得客户号</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">select</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 0);">@CusNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(128, 128, 128);">=</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">CusNo <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">from</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">CRMPSProjectM <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">where</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">ProjNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(128, 128, 128);">=</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 0);">@ProjNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">得到CRMPSContact中某专案号对应的客户号</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">update</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">CRMPSContact <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">set</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">CusNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(128, 128, 128);">=</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 0);">@CusNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">where</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">ProjNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(128, 128, 128);">=</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 0);">@ProjNo</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">执行错误回滚</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">if</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; font-weight: bold; color: rgb(0, 128, 0);">@@error</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(128, 128, 128);">!=</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; font-weight: bold; color: rgb(128, 0, 0);">0</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">begin</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">rollback</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">tran</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">return</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">end</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">END</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">提交所有变更</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">COMMIT</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">TRAN</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">关闭游标</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">CLOSE</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">CRMPSContact_cursor <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">释放游标</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">DEALLOCATE</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">CRMPSContact_cursor <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">--</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);">恢复设置</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 128, 128);"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">SET</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;">NOCOUNT</span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">OFF</span><span style="font-family: Arial; font-size: 14px; line-height: 26px;"> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" style="border: none;" alt=""></span><span style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(0, 0, 255);">GO</span></div>
试试其它关键字
游标循环
同语言下
.
SQL查询 多列合并成一行用逗号隔开
.
查看存储过程修改时间,最近执行时间
.
设置手动批量删除数据库相关进程
.
获取某个表中特定字段的所有字符串形式
.
SQL 如何去除重复的字符串
.
怎么去掉一个字段中的重复数据
.
String 去除空格 回车 换行 水平制表符
.
SQL查询和替换含有回车,空格,TAB
.
SQL SERVER 查询每日新增用户数量、次留数量
.
判断两个字符串是否存在相同的内容
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Dezai.CN
贡献的其它代码
(
4037
)
.
多线程Socket服务器模块
.
生成随机密码
.
清除浮动样式
.
弹出窗口居中
.
抓取url的函数
.
使用base HTTP验证
.
div模拟iframe嵌入效果
.
通过header转向的方法
.
Session操作类
.
执行sqlite输入插入操作后获得自动编号的ID
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3