{"id":372,"date":"2014-11-15T12:40:10","date_gmt":"2014-11-15T12:40:10","guid":{"rendered":"24b16fede9a67c9251d3e7c7161c83ac"},"modified":"2014-11-15T12:40:10","modified_gmt":"2014-11-15T12:40:10","slug":"","status":"publish","type":"post","link":"https:\/\/www.xiaobo.li\/notes\/archives\/372","title":{"rendered":"SQL Server\u6b7b\u9501\u603b\u7ed3"},"content":{"rendered":"<div style=\"text-transform:none;text-indent:0px;letter-spacing:normal;font:13px\/20px georgia, verdana, Arial, helvetica, sans-seriff;white-space:normal;margin-bottom:20px;color:#4b4b4b;word-spacing:0px;-webkit-text-stroke-width:0px;\" id=\"cnblogs_post_body\">\n<p style=\"text-indent:0px;margin:10px auto;\"><span class=\"Apple-converted-space\">\u5f53\u524d\u9501\u67e5\u770b\uff1a<\/span><\/p>\n<p style=\"text-indent:0px;margin:10px auto;\"><span class=\"Apple-converted-space\">use master<br \/>\ngo<\/span><\/p>\n<p style=\"text-indent:0px;margin:10px auto;\"><span class=\"Apple-converted-space\">--\u68c0\u7d22\u6b7b\u9501\u8fdb\u7a0b<br \/>\nselect spid, blocked, loginame, last_batch, status, cmd, hostname, program_name<br \/>\nfrom sysprocesses<br \/>\nwhere spid in<br \/>\n( select blocked from sysprocesses where blocked &lt;&gt; 0 ) or (blocked &lt;&gt;0)<\/span><\/p>\n<p style=\"text-indent:0px;margin:10px auto;\"><span class=\"Apple-converted-space\">--\u6216\u8005\uff1a<\/span><\/p>\n<p style=\"text-indent:0px;margin:10px auto;\"><span class=\"Apple-converted-space\">select request_session_id,OBJECT_NAME(resource_associated_entity_id) tableName from <br \/>\nsys.dm_tran_locks<br \/>\nwhere resource_type='OBJECT'<\/span><\/p>\n<p style=\"text-indent:0px;margin:10px auto;\"><span class=\"Apple-converted-space\">--<\/span><\/p>\n<p style=\"text-indent:0px;margin:10px auto;\"><span class=\"Apple-converted-space\"><span style=\"text-align:left;text-transform:none;background-color:#ffffff;text-indent:0px;letter-spacing:normal;display:inline !important;font:14px\/26px Arial;white-space:normal;float:none;color:#333333;word-spacing:0px;-webkit-text-stroke-width:0px;\">kill&nbsp;&nbsp; \u8fdb\u7a0b\u53f7\uff08sp_lock\/sp_who\u67e5\u627e\u6b7b\u9501\u7684\u8fdb\u7a0b\u548c\u5bf9\u8c61\uff09<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><br style=\"text-align:left;text-transform:none;background-color:#ffffff;text-indent:0px;letter-spacing:normal;font:14px\/26px Arial;white-space:normal;color:#333333;word-spacing:0px;-webkit-text-stroke-width:0px;\" \/><br \/>\n<span style=\"text-align:left;text-transform:none;background-color:#ffffff;text-indent:0px;letter-spacing:normal;display:inline !important;font:14px\/26px Arial;white-space:normal;float:none;color:#333333;word-spacing:0px;-webkit-text-stroke-width:0px;\">spid\u5c31\u662f\u9501\u4f4f\u8868\u7684\u8fdb\u7a0b<\/span><br style=\"text-align:left;text-transform:none;background-color:#ffffff;text-indent:0px;letter-spacing:normal;font:14px\/26px Arial;white-space:normal;color:#333333;word-spacing:0px;-webkit-text-stroke-width:0px;\" \/><br \/>\n<span style=\"text-align:left;text-transform:none;background-color:#ffffff;text-indent:0px;letter-spacing:normal;display:inline !important;font:14px\/26px Arial;white-space:normal;float:none;color:#333333;word-spacing:0px;-webkit-text-stroke-width:0px;\">tableName\u5c31\u662f\u88ab\u9501\u7684\u8868\u540d<\/span><br style=\"text-align:left;text-transform:none;background-color:#ffffff;text-indent:0px;letter-spacing:normal;font:14px\/26px Arial;white-space:normal;color:#333333;word-spacing:0px;-webkit-text-stroke-width:0px;\" \/><br \/>\n<span style=\"text-align:left;text-transform:none;background-color:#ffffff;text-indent:0px;letter-spacing:normal;display:inline !important;font:14px\/26px Arial;white-space:normal;float:none;color:#333333;word-spacing:0px;-webkit-text-stroke-width:0px;\">\u89e3\u9501<\/span><br style=\"text-align:left;text-transform:none;background-color:#ffffff;text-indent:0px;letter-spacing:normal;font:14px\/26px Arial;white-space:normal;color:#333333;word-spacing:0px;-webkit-text-stroke-width:0px;\" \/><br \/>\n<span style=\"text-align:left;text-transform:none;background-color:#ffffff;text-indent:0px;letter-spacing:normal;display:inline !important;font:14px\/26px Arial;white-space:normal;float:none;color:#333333;word-spacing:0px;-webkit-text-stroke-width:0px;\">kill [spid]<\/span><\/span><\/p>\n<p style=\"text-indent:0px;margin:10px auto;\">&nbsp;<\/p>\n<p style=\"text-indent:0px;margin:10px auto;\"><span class=\"Apple-converted-space\">&nbsp;<\/span><strong><span style=\"line-height:24px;font-size:12pt;\" lang=\"EN-US\">1.<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/strong><strong><span style=\"line-height:24px;font-family:\u5b8b\u4f53;font-size:12pt;\">\u6b7b\u9501\u539f\u7406<\/span><\/strong><strong><span style=\"line-height:24px;font-size:12pt;\" lang=\"EN-US\"><?xml:namespace prefix = o \/><o:p><\/o:p><\/span><\/strong><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7684\u5b9a\u4e49\uff1a\u6b7b\u9501\u662f\u6307\u5728\u4e00\u7ec4\u8fdb\u7a0b\u4e2d\u7684\u5404\u4e2a\u8fdb\u7a0b\u5747\u5360\u6709\u4e0d\u4f1a\u91ca\u653e\u7684\u8d44\u6e90\uff0c\u4f46\u56e0\u4e92\u76f8\u7533\u8bf7\u88ab\u5176\u4ed6\u8fdb\u7a0b\u6240\u7ad9\u7528\u4e0d\u4f1a\u91ca\u653e\u7684\u8d44\u6e90\u800c\u5904\u4e8e\u7684\u4e00\u79cd\u6c38\u4e45\u7b49\u5f85\u72b6\u6001\u3002<\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6b7b\u9501\u7684\u56db\u4e2a\u5fc5\u8981\u6761\u4ef6\uff1a<br \/>\n<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e92\u65a5\u6761\u4ef6<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(Mutual exclusion)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1a\u8d44\u6e90\u4e0d\u80fd\u88ab\u5171\u4eab\uff0c\u53ea\u80fd\u7531\u4e00\u4e2a\u8fdb\u7a0b\u4f7f\u7528\u3002<br \/>\n<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8bf7\u6c42\u4e0e\u4fdd\u6301\u6761\u4ef6<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(Hold and wait)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1a\u5df2\u7ecf\u5f97\u5230\u8d44\u6e90\u7684\u8fdb\u7a0b\u53ef\u4ee5\u518d\u6b21\u7533\u8bf7\u65b0\u7684\u8d44\u6e90\u3002<br \/>\n<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u975e\u5265\u593a\u6761\u4ef6<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(No pre-emption)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1a\u5df2\u7ecf\u5206\u914d\u7684\u8d44\u6e90\u4e0d\u80fd\u4ece\u76f8\u5e94\u7684\u8fdb\u7a0b\u4e2d\u88ab\u5f3a\u5236\u5730\u5265\u593a\u3002<br \/>\n<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5faa\u73af\u7b49\u5f85\u6761\u4ef6<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(Circular wait)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1a\u7cfb\u7edf\u4e2d\u82e5\u5e72\u8fdb\u7a0b\u7ec4\u6210\u73af\u8def\uff0c\u8be5\u73af\u8def\u4e2d\u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u5728\u7b49\u5f85\u76f8\u90bb\u8fdb\u7a0b\u6b63\u5360\u7528\u7684\u8d44\u6e90\u3002<\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><o:p><\/o:p><\/span><\/p>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5bf9\u5e94\u5230<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL Server<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e2d\uff0c\u5f53\u5728\u4e24\u4e2a\u6216\u591a\u4e2a\u4efb\u52a1\u4e2d\uff0c\u5982\u679c\u6bcf\u4e2a\u4efb\u52a1\u9501\u5b9a\u4e86\u5176\u4ed6\u4efb\u52a1\u8bd5\u56fe\u9501\u5b9a\u7684\u8d44\u6e90\uff0c\u6b64\u65f6\u4f1a\u9020\u6210\u8fd9\u4e9b\u4efb\u52a1\u6c38\u4e45\u963b\u585e\uff0c\u4ece\u800c\u51fa\u73b0\u6b7b\u9501\uff1b\u8fd9\u4e9b\u8d44\u6e90\u53ef\u80fd\u662f<span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\uff1a\u5355\u884c<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">(RID<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\uff0c\u5806\u4e2d\u7684\u5355\u884c<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">)<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\u3001\u7d22\u5f15\u4e2d\u7684\u952e<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">(KEY<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\uff0c\u884c\u9501<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">)<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\u3001\u9875<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">(PAG<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\uff0c<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">8KB)<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\u3001\u533a\u7ed3\u6784<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">(EXT<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\uff0c\u8fde\u7eed\u7684<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">8<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\u9875<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">)<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\u3001\u5806\u6216<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">B<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\u6811<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">(HOBT)<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\u3001\u8868<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">(TAB<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\uff0c\u5305\u62ec\u6570\u636e\u548c\u7d22\u5f15<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">)<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\u3001\u6587\u4ef6<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">(File<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\uff0c\u6570\u636e\u5e93\u6587\u4ef6<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">)<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\u3001\u5e94\u7528\u7a0b\u5e8f\u4e13\u7528\u8d44\u6e90<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">(APP)<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\u3001\u5143\u6570\u636e<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">(METADATA)<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\u3001\u5206\u914d\u5355\u5143<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">(Allocation_Unit)<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\u3001\u6574\u4e2a\u6570\u636e\u5e93<\/span><span style=\"line-height:21px;font-family:'Times New Roman';font-size:10.5pt;\" lang=\"EN-US\">(DB)<\/span><span style=\"line-height:21px;font-family:\u5b8b\u4f53;font-size:10.5pt;\">\u3002<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e00\u4e2a\u6b7b\u9501\u793a\u4f8b\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/span><\/p>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\"><a id=\"ematt:234\" href=\"\/notes\/content\/uploadfile\/201411\/c1951416026594.jpg\" target=\"_blank\"><img decoding=\"async\" border=\"0\" alt=\"\u70b9\u51fb\u67e5\u770b\u539f\u56fe\" src=\"\/notes\/content\/uploadfile\/201411\/c1951416026594.jpg\" \/><\/a><br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;\u8bf4\u660e\uff1a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">T1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u3001<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">T2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8868\u793a\u4e24\u4e2a\u4efb\u52a1\uff1b<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">R1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u548c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">R2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8868\u793a\u4e24\u4e2a\u8d44\u6e90\uff1b\u7531\u8d44\u6e90\u6307\u5411\u4efb\u52a1\u7684\u7bad\u5934<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5982<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">R1-&gt;T1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">R2-&gt;T2)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8868\u793a\u8be5\u8d44\u6e90\u88ab\u6539\u4efb\u52a1\u6240\u6301\u6709\uff1b\u7531\u4efb\u52a1\u6307\u5411\u8d44\u6e90\u7684\u7bad\u5934<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5982<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">T1-&gt;S2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">T2-&gt;S1)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8868\u793a\u8be5\u4efb\u52a1\u6b63\u5728\u8bf7\u6c42\u5bf9\u5e94\u76ee\u6807\u8d44\u6e90\uff1b<br \/>\n<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">&nbsp;&nbsp;&nbsp;&nbsp;\u5176\u6ee1\u8db3\u4e0a\u9762\u6b7b\u9501\u7684\u56db\u4e2a\u5fc5\u8981\u6761\u4ef6\uff1a<br \/>\n<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(1).<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e92\u65a5\uff1a\u8d44\u6e90<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u548c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e0d\u80fd\u88ab\u5171\u4eab\uff0c\u540c\u4e00\u65f6\u95f4\u53ea\u80fd\u7531\u4e00\u4e2a\u4efb\u52a1\u4f7f\u7528\uff1b<br \/>\n<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(2).<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8bf7\u6c42\u4e0e\u4fdd\u6301\u6761\u4ef6\uff1a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">T1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6301\u6709<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7684\u540c\u65f6\uff0c\u8bf7\u6c42<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1b<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">T2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6301\u6709<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7684\u540c\u65f6\u8bf7\u6c42<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1b<br \/>\n<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(3).<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u975e\u5265\u593a\u6761\u4ef6\uff1a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">T1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u65e0\u6cd5\u4ece<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">T2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e0a\u5265\u593a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">T2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e5f\u65e0\u6cd5\u4ece<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">T1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e0a\u5265\u593a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1b<br \/>\n<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(4).<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5faa\u73af\u7b49\u5f85\u6761\u4ef6\uff1a\u4e0a\u56fe\u4e2d\u7684\u7bad\u5934\u6784\u6210\u73af\u8def\uff0c\u5b58\u5728\u5faa\u73af\u7b49\u5f85\u3002<\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><o:p>&nbsp;<\/o:p><\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><strong><span style=\"line-height:24px;font-size:12pt;\" lang=\"EN-US\">2.<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/strong><strong><span style=\"line-height:24px;font-family:\u5b8b\u4f53;font-size:12pt;\">\u6b7b\u9501\u6392\u67e5<\/span><\/strong><strong><span style=\"line-height:24px;font-size:12pt;\" lang=\"EN-US\"><o:p><\/o:p><\/span><\/strong><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\">(1).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4f7f\u7528<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL Server<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7684\u7cfb\u7edf\u5b58\u50a8\u8fc7\u7a0b<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">sp_who<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u548c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">sp_lock<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u6570\u636e\u5e93\u4e2d\u7684\u9501\u60c5\u51b5\uff1b\u8fdb\u800c\u6839\u636e<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">objectID(@objID)(SQL Server 2005)\/ object_name(@objID)(Sql Server 2000)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u53ef\u4ee5\u67e5\u770b\u54ea\u4e2a\u8d44\u6e90\u88ab\u9501\uff0c\u7528<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">dbcc ld(@blk)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u53ef\u4ee5\u67e5\u770b\u6700\u540e\u4e00\u6761\u53d1\u751f\u7ed9<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL Server<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Sql<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8bed\u53e5\uff1b<\/span><\/p>\n<p><span style=\"line-height:19px;\" lang=\"EN-US\"><\/p>\n<pre class=\"brush:sql; toolbar: true; auto-links: true;\">CREATE Table #Who(spid int,\r\n\r\n    ecid int,\r\n\r\n    status nvarchar(50),\r\n\r\n    loginname nvarchar(50),\r\n\r\n    hostname nvarchar(50),\r\n\r\n    blk int,\r\n\r\n    dbname nvarchar(50),\r\n\r\n    cmd nvarchar(50),\r\n\r\n    request_ID int);\r\n\r\n\r\n\r\nCREATE Table #Lock(spid int,\r\n\r\n    dpid int,\r\n\r\n    objid int,\r\n\r\n    indld int,\r\n\r\n    [Type] nvarchar(20),\r\n\r\n    Resource nvarchar(50),\r\n\r\n    Mode nvarchar(10),\r\n\r\n    Status nvarchar(10)\r\n\r\n);\r\n\r\n\r\n\r\nINSERT INTO #Who\r\n\r\n    EXEC sp_who active  --\u770b\u54ea\u4e2a\u5f15\u8d77\u7684\u963b\u585e\uff0cblk \r\n\r\nINSERT INTO #Lock\r\n\r\n    EXEC sp_lock  --\u770b\u9501\u4f4f\u4e86\u90a3\u4e2a\u8d44\u6e90id\uff0cobjid \r\n\r\n\r\n\r\nDECLARE @DBName nvarchar(20);\r\n\r\nSET @DBName='NameOfDataBase'\r\n\r\n\r\n\r\nSELECT #Who.* FROM #Who WHERE dbname=@DBName\r\n\r\nSELECT #Lock.* FROM #Lock\r\n\r\n    JOIN #Who\r\n\r\n        ON #Who.spid=#Lock.spid\r\n\r\n            AND dbname=@DBName;\r\n\r\n\r\n\r\n--\u6700\u540e\u53d1\u9001\u5230SQL Server\u7684\u8bed\u53e5\r\n\r\nDECLARE crsr Cursor FOR\r\n\r\n    SELECT blk FROM #Who WHERE dbname=@DBName AND blk&lt;&gt;0;\r\n\r\nDECLARE @blk int;\r\n\r\nopen crsr;\r\n\r\nFETCH NEXT FROM crsr INTO @blk;\r\n\r\nWHILE (@@FETCH_STATUS = 0)\r\n\r\nBEGIN;\r\n\r\n    dbcc inputbuffer(@blk);\r\n\r\n    FETCH NEXT FROM crsr INTO @blk;\r\n\r\nEND;\r\n\r\nclose crsr;\r\n\r\nDEALLOCATE crsr;\r\n\r\n\r\n\r\n--\u9501\u5b9a\u7684\u8d44\u6e90\r\n\r\nSELECT #Who.spid,hostname,objid,[type],mode,object_name(objid) as objName FROM #Lock\r\n\r\n    JOIN #Who\r\n\r\n        ON #Who.spid=#Lock.spid\r\n\r\n            AND dbname=@DBName\r\n\r\n    WHERE objid&lt;&gt;0;\r\n\r\n\r\n\r\nDROP Table #Who;\r\n\r\nDROP Table #Lock;<\/pre>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n(2).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4f7f\u7528<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span class=\"Apple-converted-space\">&nbsp;<\/span>SQL Server Profiler<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5206\u6790\u6b7b\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">:<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5c06<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span class=\"Apple-converted-space\">&nbsp;<\/span>Deadlock graph<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e8b\u4ef6\u7c7b\u6dfb\u52a0\u5230\u8ddf\u8e2a\u3002\u6b64\u4e8b\u4ef6\u7c7b\u4f7f\u7528\u6b7b\u9501\u6d89\u53ca\u5230\u7684\u8fdb\u7a0b\u548c\u5bf9\u8c61\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span class=\"Apple-converted-space\">&nbsp;<\/span>XML<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6570\u636e\u586b\u5145\u8ddf\u8e2a\u4e2d\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span class=\"Apple-converted-space\">&nbsp;<\/span>TextData<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6570\u636e\u5217\u3002<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL Server<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e8b\u4ef6\u63a2\u67e5\u5668<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">&nbsp;<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u53ef\u4ee5\u5c06<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span class=\"Apple-converted-space\">&nbsp;<\/span>XML<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6587\u6863\u63d0\u53d6\u5230\u6b7b\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span class=\"Apple-converted-space\">&nbsp;<\/span>XML (.xdl)<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6587\u4ef6\u4e2d\uff0c\u4ee5\u540e\u53ef\u5728<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span class=\"Apple-converted-space\">&nbsp;<\/span>SQL Server Management Studio<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e2d\u67e5\u770b\u8be5\u6587\u4ef6\u3002<\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><o:p>&nbsp;<\/o:p><\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><strong><span style=\"line-height:24px;font-size:12pt;\" lang=\"EN-US\">3.<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/strong><strong><span style=\"line-height:24px;font-family:\u5b8b\u4f53;font-size:12pt;\">\u907f\u514d\u6b7b\u9501<\/span><\/strong><strong><span style=\"line-height:24px;font-size:12pt;\" lang=\"EN-US\"><o:p><\/o:p><\/span><\/strong><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e0a\u9762<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e2d\u5217\u51fa\u4e86\u6b7b\u9501\u7684\u56db\u4e2a\u5fc5\u8981\u6761\u4ef6\uff0c\u6211\u4eec\u53ea\u8981\u60f3\u529e\u6cd5\u7834\u5176\u4e2d\u7684\u4efb\u610f\u4e00\u4e2a\u6216\u591a\u4e2a\u6761\u4ef6\uff0c\u5c31\u53ef\u4ee5\u907f\u514d\u6b7b\u9501\u53d1\u751f\uff0c\u4e00\u822c\u6709\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(FROM Sql Server 2005<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8054\u673a\u4e1b\u4e66<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1a<br \/>\n<\/span><strong><span style=\"line-height:19px;\" lang=\"EN-US\">(1).<\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6309\u540c\u4e00\u987a\u5e8f\u8bbf\u95ee\u5bf9\u8c61\u3002<\/span><\/strong><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6ce8\uff1a\u907f\u514d\u51fa\u73b0\u5faa\u73af<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<br \/>\n<\/span><strong><span style=\"line-height:19px;\" lang=\"EN-US\">(2).<\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u907f\u514d\u4e8b\u52a1\u4e2d\u7684\u7528\u6237\u4ea4\u4e92\u3002<\/span><\/strong><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6ce8\uff1a\u51cf\u5c11\u6301\u6709\u8d44\u6e90\u7684\u65f6\u95f4\uff0c\u8f83\u5c11\u9501\u7ade\u4e89<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<br \/>\n<\/span><strong><span style=\"line-height:19px;\" lang=\"EN-US\">(3).<\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4fdd\u6301\u4e8b\u52a1\u7b80\u77ed\u5e76\u5904\u4e8e\u4e00\u4e2a\u6279\u5904\u7406\u4e2d\u3002<\/span><\/strong><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6ce8\uff1a\u540c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(2)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u51cf\u5c11\u6301\u6709\u8d44\u6e90\u7684\u65f6\u95f4<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<br \/>\n<\/span><strong><span style=\"line-height:19px;\" lang=\"EN-US\">(4).<\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4f7f\u7528\u8f83\u4f4e\u7684\u9694\u79bb\u7ea7\u522b\u3002<\/span><\/strong><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6ce8\uff1a\u4f7f\u7528\u8f83\u4f4e\u7684\u9694\u79bb\u7ea7\u522b\uff08\u4f8b\u5982\u5df2\u63d0\u4ea4\u8bfb\uff09\u6bd4\u4f7f\u7528\u8f83\u9ad8\u7684\u9694\u79bb\u7ea7\u522b\uff08\u4f8b\u5982\u53ef\u5e8f\u5217\u5316\uff09\u6301\u6709\u5171\u4eab\u9501\u7684\u65f6\u95f4\u66f4\u77ed\uff0c\u51cf\u5c11\u9501\u7ade\u4e89<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<br \/>\n<\/span><strong><span style=\"line-height:19px;\" lang=\"EN-US\">(5).<\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4f7f\u7528\u57fa\u4e8e\u884c\u7248\u672c\u63a7\u5236\u7684\u9694\u79bb\u7ea7\u522b<\/span><\/strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">2005<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e2d\u652f\u6301\u5feb\u7167\u4e8b\u52a1\u9694\u79bb\u548c\u6307\u5b9a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">READ_COMMITTED<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9694\u79bb\u7ea7\u522b\u7684\u4e8b\u52a1\u4f7f\u7528\u884c\u7248\u672c\u63a7\u5236\uff0c\u53ef\u4ee5\u5c06\u8bfb\u4e0e\u5199\u64cd\u4f5c\u4e4b\u95f4\u53d1\u751f\u7684\u6b7b\u9501\u51e0\u7387\u964d\u81f3\u6700\u4f4e\uff1a<br \/>\n<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SET ALLOW_SNAPSHOT_ISOLATION ON --<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e8b\u52a1\u53ef\u4ee5\u6307\u5b9a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span class=\"Apple-converted-space\">&nbsp;<\/span>SNAPSHOT<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">;<br \/>\n<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SET READ_COMMITTED_SNAPSHOT ON<span style=\"line-height:19px;\">&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span>--<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6307\u5b9a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span class=\"Apple-converted-space\">&nbsp;<\/span>READ_COMMITTED<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9694\u79bb\u7ea7\u522b\u7684\u4e8b\u52a1\u5c06\u4f7f\u7528\u884c\u7248\u672c\u63a7\u5236\u800c\u4e0d\u662f\u9501\u5b9a\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6ca1\u6709\u5f00\u542f\u6b64\u9009\u9879\uff0c\u6ca1\u6709\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">with nolock<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u63d0\u793a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SELECT<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8bed\u53e5\u4f1a\u5bf9\u8bf7\u6c42\u7684\u8d44\u6e90\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5171\u4eab\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1b\u800c\u5f00\u542f\u4e86\u6b64\u9009\u9879\u540e\uff0c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SELECT<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e0d\u4f1a\u5bf9\u8bf7\u6c42\u7684\u8d44\u6e90\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\u3002<br \/>\n<\/span><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6ce8\u610f\uff1a<\/span><\/strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8bbe\u7f6e<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span class=\"Apple-converted-space\">&nbsp;<\/span>READ_COMMITTED_SNAPSHOT<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9009\u9879\u65f6\uff0c\u6570\u636e\u5e93\u4e2d\u53ea\u5141\u8bb8\u5b58\u5728\u6267\u884c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span class=\"Apple-converted-space\">&nbsp;<\/span>ALTER DATABASE<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u547d\u4ee4\u7684\u8fde\u63a5\u3002\u5728<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span class=\"Apple-converted-space\">&nbsp;<\/span>ALTER DATABASE<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5b8c\u6210\u4e4b\u524d\uff0c\u6570\u636e\u5e93\u4e2d\u51b3\u4e0d\u80fd\u6709\u5176\u4ed6\u6253\u5f00\u7684\u8fde\u63a5\u3002\u6570\u636e\u5e93\u4e0d\u5fc5\u4e00\u5b9a\u8981\u5904\u4e8e\u5355\u7528\u6237\u6a21\u5f0f\u4e2d\u3002<br \/>\n<\/span><strong><span style=\"line-height:19px;\" lang=\"EN-US\">(6).<\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4f7f\u7528\u7ed1\u5b9a\u8fde\u63a5<\/span><\/strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u3002<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6ce8\uff1a\u7ed1\u5b9a\u4f1a\u8bdd\u6709\u5229\u4e8e\u5728\u540c\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\u7684\u591a\u4e2a\u4f1a\u8bdd\u4e4b\u95f4\u534f\u8c03\u64cd\u4f5c\u3002\u7ed1\u5b9a\u4f1a\u8bdd\u5141\u8bb8\u4e00\u4e2a\u6216\u591a\u4e2a\u4f1a\u8bdd<strong>\u5171\u4eab\u76f8\u540c\u7684\u4e8b\u52a1\u548c\u9501<\/strong><\/span><strong><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4f46\u6bcf\u4e2a\u56de\u8bdd\u4fdd\u7559\u5176\u81ea\u5df1\u7684\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><\/strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u5e76\u53ef\u4ee5\u4f7f\u7528\u540c\u4e00\u6570\u636e\uff0c\u800c\u4e0d\u4f1a\u6709\u9501\u51b2\u7a81\u3002\u53ef\u4ee5\u4ece\u540c\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u5185\u7684\u591a\u4e2a\u4f1a\u8bdd\u4e2d\u521b\u5efa\u7ed1\u5b9a\u4f1a\u8bdd\uff0c\u4e5f\u53ef\u4ee5\u4ece\u5305\u542b\u4e0d\u540c\u4f1a\u8bdd\u7684\u591a\u4e2a\u5e94\u7528\u7a0b\u5e8f\u4e2d\u521b\u5efa\u7ed1\u5b9a\u4f1a\u8bdd\u3002\u5728\u4e00\u4e2a\u4f1a\u8bdd\u4e2d\u5f00\u542f\u4e8b\u52a1<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(begin tran)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u540e\uff0c\u8c03\u7528<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">exec sp_getbindtoken @Token out;<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6765\u53d6\u5f97<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Token<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u7136\u540e\u4f20\u5165\u53e6\u4e00\u4e2a\u4f1a\u8bdd\u5e76\u6267\u884c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">EXEC sp_bindsession @Token<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6765\u8fdb\u884c\u7ed1\u5b9a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6700\u540e\u7684\u793a\u4f8b\u4e2d\u6f14\u793a\u4e86\u7ed1\u5b9a\u8fde\u63a5<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u3002<\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><o:p>&nbsp;<\/o:p><\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><strong><span style=\"line-height:24px;font-size:12pt;\" lang=\"EN-US\">4.<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/strong><strong><span style=\"line-height:24px;font-family:\u5b8b\u4f53;font-size:12pt;\">\u6b7b\u9501\u5904\u7406\u65b9\u6cd5\uff1a<\/span><\/strong><strong><span style=\"line-height:24px;font-size:12pt;\" lang=\"EN-US\"><o:p><\/o:p><\/span><\/strong><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\">(1).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6839\u636e<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e2d\u63d0\u4f9b\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">sql<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u67e5\u770b\u90a3\u4e2a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">spid<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5904\u4e8e<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">wait<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u72b6\u6001\uff0c\u7136\u540e\u7528<\/span><strong><span style=\"line-height:19px;\" lang=\"EN-US\">kill spid<\/span><\/strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6765\u5e72\u6389<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5373\u7834\u574f\u6b7b\u9501\u7684\u7b2c\u56db\u4e2a\u5fc5\u8981\u6761\u4ef6<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">:<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5faa\u73af\u7b49\u5f85<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1b\u5f53\u7136\u8fd9\u53ea\u662f\u4e00\u79cd\u4e34\u65f6\u89e3\u51b3\u65b9\u6848\uff0c\u6211\u4eec\u603b\u4e0d\u80fd\u5728\u9047\u5230\u6b7b\u9501\u5c31\u5728\u7528\u6237\u7684\u751f\u4ea7\u73af\u5883\u4e0a\u6392\u67e5\u6b7b\u9501\u3001<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Kill sp<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u6211\u4eec\u5e94\u8be5\u8003\u8651\u5982\u4f55\u53bb\u907f\u514d\u6b7b\u9501\u3002<\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\">(2).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4f7f\u7528<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SET LOCK_TIMEOUT timeout_period(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5355\u4f4d\u4e3a\u6beb\u79d2<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6765<strong>\u8bbe\u5b9a\u9501\u8bf7\u6c42\u8d85\u65f6<\/strong>\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6570\u636e\u5e93\u6ca1\u6709\u8d85\u65f6\u671f\u9650<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(timeout_period<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u503c\u4e3a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">-1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u53ef\u4ee5\u7528<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SELECT @@LOCK_TIMEOUT<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6765\u67e5\u770b\u8be5\u503c\uff0c\u5373\u65e0\u9650\u671f\u7b49\u5f85<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u3002\u5f53\u8bf7\u6c42\u9501\u8d85\u8fc7<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">timeout_period<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u65f6\uff0c\u5c06\u8fd4\u56de\u9519\u8bef\u3002<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">timeout_period<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u503c\u4e3a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">0<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u65f6\u8868\u793a\u6839\u672c\u4e0d\u7b49\u5f85\uff0c\u4e00\u9047\u5230\u9501\u5c31\u8fd4\u56de\u6d88\u606f\u3002\u8bbe\u7f6e\u9501\u8bf7\u6c42\u8d85\u65f6\uff0c\u7834\u73af\u4e86\u6b7b\u9501\u7684\u7b2c\u4e8c\u4e2a\u5fc5\u8981\u6761\u4ef6<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8bf7\u6c42\u4e0e\u4fdd\u6301\u6761\u4ef6<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u3002<\/span><\/p>\n<div style=\"border-bottom:#cccccc 1px solid;border-left:#cccccc 1px solid;padding-bottom:5px;background-color:#f5f5f5;margin:5px 0px;padding-left:5px;padding-right:5px;font-family:'Courier New' !important;color:#000000;font-size:12px !important;overflow:auto;border-top:#cccccc 1px solid;border-right:#cccccc 1px solid;padding-top:5px;\" class=\"cnblogs_code\"><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">\u670d\u52a1\u5668:&nbsp;\u6d88\u606f&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">1222<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">\uff0c\u7ea7\u522b&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">16<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">\uff0c\u72b6\u6001&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">50<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">\uff0c\u884c&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\"><br \/>\n\u5df2\u8d85\u8fc7\u4e86\u9501\u8bf7\u6c42\u8d85\u65f6\u65f6\u6bb5\u3002<\/span><\/div>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;background-color:#d9d9d9;\" lang=\"EN-US\"><o:p><\/o:p><\/span><\/p>\n<p><span style=\"line-height:19px;\" lang=\"EN-US\">(3). SQL Server<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5185\u90e8\u6709\u4e00\u4e2a<strong>\u9501\u76d1\u89c6\u5668\u7ebf\u7a0b\u6267\u884c\u6b7b\u9501\u68c0\u67e5<\/strong>\uff0c\u9501\u76d1\u89c6\u5668\u5bf9\u7279\u5b9a\u7ebf\u7a0b\u542f\u52a8\u6b7b\u9501\u641c\u7d22\u65f6\uff0c\u4f1a\u6807\u8bc6\u7ebf\u7a0b\u6b63\u5728\u7b49\u5f85\u7684\u8d44\u6e90\uff1b\u7136\u540e\u67e5\u627e\u7279\u5b9a\u8d44\u6e90\u7684\u6240\u6709\u8005\uff0c\u5e76\u9012\u5f52\u5730\u7ee7\u7eed\u6267\u884c\u5bf9\u90a3\u4e9b\u7ebf\u7a0b\u7684\u6b7b\u9501\u641c\u7d22\uff0c\u76f4\u5230\u627e\u5230\u4e00\u4e2a\u6784\u6210\u6b7b\u9501\u6761\u4ef6\u7684\u5faa\u73af\u3002\u68c0\u6d4b\u5230\u6b7b\u9501\u540e\uff0c\u6570\u636e\u5e93\u5f15\u64ce<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">&nbsp;<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9009\u62e9\u8fd0\u884c\u56de\u6eda\u5f00\u9500\u6700\u5c0f\u7684\u4e8b\u52a1\u7684\u4f1a\u8bdd\u4f5c\u4e3a\u6b7b\u9501\u727a\u7272\u54c1\uff0c\u8fd4\u56de<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">1205<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9519\u8bef\uff0c\u56de\u6eda\u6b7b\u9501\u727a\u7272\u54c1\u7684\u4e8b\u52a1\u5e76\u91ca\u653e\u8be5\u4e8b\u52a1\u6301\u6709\u7684\u6240\u6709\u9501\uff0c\u4f7f\u5176\u4ed6\u7ebf\u7a0b\u7684\u4e8b\u52a1\u53ef\u4ee5\u8bf7\u6c42\u8d44\u6e90\u5e76\u7ee7\u7eed\u8fd0\u884c\u3002<\/span> <\/p>\n<p style=\"text-indent:0px;margin:10px auto;\">\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><o:p>&nbsp;<\/o:p><\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><strong><span style=\"line-height:24px;font-size:12pt;\" lang=\"EN-US\">5.<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/strong><strong><span style=\"line-height:24px;font-family:\u5b8b\u4f53;font-size:12pt;\">\u4e24\u4e2a\u6b7b\u9501\u793a\u4f8b\u53ca\u89e3\u51b3\u65b9\u6cd5<\/span><\/strong><strong><span style=\"line-height:24px;font-size:12pt;\" lang=\"EN-US\"><o:p><\/o:p><\/span><\/strong><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><strong><span style=\"line-height:19px;\" lang=\"EN-US\">5.1 SQL<\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6b7b\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><o:p><\/o:p><\/span><\/strong><\/p>\n<p style=\"line-height:19px;text-indent:21pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><strong>(1).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/strong><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\"><strong>\u6d4b\u8bd5\u7528\u7684\u57fa\u7840\u6570\u636e\uff1a<\/strong><\/span><\/p>\n<div style=\"border-bottom:#cccccc 1px solid;border-left:#cccccc 1px solid;padding-bottom:5px;background-color:#f5f5f5;margin:5px 0px;padding-left:5px;padding-right:5px;font-family:'Courier New' !important;color:#000000;font-size:12px !important;overflow:auto;border-top:#cccccc 1px solid;border-right:#cccccc 1px solid;padding-top:5px;\" class=\"cnblogs_code\"><img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">CREATE<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">TABLE<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;Lock1(C1&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">int<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">default<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">(<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;font-weight:bold;\">0<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">));<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">CREATE<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">TABLE<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;Lock2(C1&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">int<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">default<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">(<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;font-weight:bold;\">0<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">));<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">INSERT<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">INTO<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;Lock1&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">VALUES<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">(<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;font-weight:bold;\">1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">);<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">INSERT<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">INTO<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;Lock2&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">VALUES<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">(<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;font-weight:bold;\">1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">);<\/span><\/div>\n<p style=\"line-height:19px;text-indent:21pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;background-color:#d9d9d9;\" lang=\"EN-US\"><o:p><\/o:p><\/span><\/p>\n<p><strong><span style=\"line-height:19px;\" lang=\"EN-US\">(2).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5f00\u4e24\u4e2a\u67e5\u8be2\u7a97\u53e3\uff0c\u5206\u522b\u6267\u884c\u4e0b\u9762\u4e24\u6bb5<\/span><\/strong><span style=\"line-height:19px;\" lang=\"EN-US\"><strong>sql<\/strong> <\/p>\n<p style=\"text-indent:0px;margin:10px auto;\">\n<div style=\"border-bottom:#cccccc 1px solid;border-left:#cccccc 1px solid;padding-bottom:5px;background-color:#f5f5f5;margin:5px 0px;padding-left:5px;padding-right:5px;font-family:'Courier New' !important;color:#000000;font-size:12px !important;overflow:auto;border-top:#cccccc 1px solid;border-right:#cccccc 1px solid;padding-top:5px;\" class=\"cnblogs_code\"><img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008080;font-size:12px !important;\">--<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008080;font-size:12px !important;\">Query&nbsp;1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008080;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Begin<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Tran<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>&nbsp;&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Update<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;Lock1&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Set<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;C1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#808080;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">C1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#808080;font-size:12px !important;\">+<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;font-weight:bold;\">1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">;<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>&nbsp;&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">WaitFor<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;Delay&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#ff0000;font-size:12px !important;\">'<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#ff0000;font-size:12px !important;\">00:01:00<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#ff0000;font-size:12px !important;\">'<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">;<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>&nbsp;&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">SELECT<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#808080;font-size:12px !important;\">*<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">FROM<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;Lock2<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Rollback<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Tran<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">;<\/span><\/div>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">&nbsp;<\/p>\n<div style=\"border-bottom:#cccccc 1px solid;border-left:#cccccc 1px solid;padding-bottom:5px;background-color:#f5f5f5;margin:5px 0px;padding-left:5px;padding-right:5px;font-family:'Courier New' !important;color:#000000;font-size:12px !important;overflow:auto;border-top:#cccccc 1px solid;border-right:#cccccc 1px solid;padding-top:5px;\" class=\"cnblogs_code\"><img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008080;font-size:12px !important;\">--<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008080;font-size:12px !important;\">Query&nbsp;2<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008080;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Begin<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Tran<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>&nbsp;&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Update<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;Lock2&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Set<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;C1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#808080;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">C1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#808080;font-size:12px !important;\">+<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;font-weight:bold;\">1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">;<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>&nbsp;&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">WaitFor<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;Delay&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#ff0000;font-size:12px !important;\">'<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#ff0000;font-size:12px !important;\">00:01:00<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#ff0000;font-size:12px !important;\">'<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">;<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>&nbsp;&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">SELECT<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#808080;font-size:12px !important;\">*<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">FROM<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;Lock1<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Rollback<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Tran<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">;<\/span><\/div>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">&nbsp;<\/p>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e0a\u9762\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e2d\u6709\u4e00\u53e5<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">WaitFor Delay '00:01:00'<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u7528\u4e8e\u7b49\u5f85<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5206\u949f\uff0c\u4ee5\u65b9\u4fbf\u67e5\u770b\u9501\u7684\u60c5\u51b5\u3002<\/span><\/p>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><strong><span style=\"line-height:19px;\" lang=\"EN-US\">(3).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u67e5\u770b\u9501\u60c5\u51b5<\/span><\/strong><\/p>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5728\u6267\u884c\u4e0a\u9762\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">WaitFor<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8bed\u53e5\u671f\u95f4\uff0c\u6267\u884c\u7b2c\u4e8c\u8282\u4e2d\u63d0\u4f9b\u7684\u8bed\u53e5\u6765\u67e5\u770b\u9501\u4fe1\u606f\uff1a<\/span><\/p>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><a id=\"ematt:235\" href=\"\/notes\/content\/uploadfile\/201411\/8f621416026594.jpg\" target=\"_blank\"><img decoding=\"async\" border=\"0\" alt=\"\u70b9\u51fb\u67e5\u770b\u539f\u56fe\" src=\"\/notes\/content\/uploadfile\/201411\/8f621416026594.jpg\" \/><\/a>Query1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e2d\uff0c\u6301\u6709<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Lock1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e2d\u7b2c\u4e00\u884c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8868\u4e2d\u53ea\u6709\u4e00\u884c\u6570\u636e<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7684\u884c\u6392\u4ed6\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(RID:X)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u5e76\u6301\u6709\u8be5\u884c\u6240\u5728\u9875\u7684\u610f\u5411\u66f4\u65b0\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(PAG:IX)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u3001\u8be5\u8868\u7684\u610f\u5411\u66f4\u65b0\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(TAB:IX)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1b<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Query2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e2d\uff0c\u6301\u6709<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Lock2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e2d\u7b2c\u4e00\u884c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8868\u4e2d\u53ea\u6709\u4e00\u884c\u6570\u636e<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7684\u884c\u6392\u4ed6\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(RID:X)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u5e76\u6301\u6709\u8be5\u884c\u6240\u5728\u9875\u7684\u610f\u5411\u66f4\u65b0\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(PAG:IX)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u3001\u8be5\u8868\u7684\u610f\u5411\u66f4\u65b0\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(TAB:IX)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1b<\/span><\/p>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6267\u884c\u5b8c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Waitfor<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Query1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u67e5\u8be2<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Lock2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u8bf7\u6c42\u5728\u8d44\u6e90\u4e0a\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\uff0c\u4f46\u8be5\u884c\u5df2\u7ecf\u88ab<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Query2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u52a0\u4e0a\u4e86<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">X<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\uff1b<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Query2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u67e5\u8be2<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Lock1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u8bf7\u6c42\u5728\u8d44\u6e90\u4e0a\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\uff0c\u4f46\u8be5\u884c\u5df2\u7ecf\u88ab<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Query1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u52a0\u4e0a\u4e86<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">X<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\uff1b\u4e8e\u662f\u4e24\u4e2a\u67e5\u8be2\u6301\u6709\u8d44\u6e90\u5e76\u4e92\u4e0d\u76f8\u8ba9\uff0c\u6784\u6210\u6b7b\u9501\u3002<\/span><\/p>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><strong><span style=\"line-height:19px;\" lang=\"EN-US\">(4).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u89e3\u51b3\u529e\u6cd5<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><o:p><\/o:p><\/span><\/strong><\/p>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\">a).<span class=\"Apple-converted-space\">&nbsp;<\/span><strong>SQL Server<\/strong><\/span><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u81ea\u52a8\u9009\u62e9\u4e00\u6761<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL<\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4f5c\u6b7b\u9501\u727a\u7272\u54c1<\/span><\/strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1a\u8fd0\u884c\u5b8c\u4e0a\u9762\u7684\u4e24\u4e2a\u67e5\u8be2\u540e\uff0c\u6211\u4eec\u4f1a\u53d1\u73b0\u6709\u4e00\u6761<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u80fd\u6b63\u5e38\u6267\u884c\u5b8c\u6bd5\uff0c\u800c\u53e6\u4e00\u4e2a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5219\u62a5\u5982\u4e0b\u9519\u8bef\uff1a<\/span><\/p>\n<div style=\"border-bottom:#cccccc 1px solid;border-left:#cccccc 1px solid;padding-bottom:5px;background-color:#f5f5f5;margin:5px 0px;padding-left:5px;padding-right:5px;font-family:'Courier New' !important;color:#000000;font-size:12px !important;overflow:auto;border-top:#cccccc 1px solid;border-right:#cccccc 1px solid;padding-top:5px;\" class=\"cnblogs_code\"><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">\u670d\u52a1\u5668:&nbsp;\u6d88\u606f&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">1205<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">\uff0c\u7ea7\u522b&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">13<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">\uff0c\u72b6\u6001&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">50<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">\uff0c\u884c&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\"><br \/>\n\u4e8b\u52a1\uff08\u8fdb\u7a0b&nbsp;ID&nbsp;&nbsp;xx\uff09\u4e0e\u53e6\u4e00\u4e2a\u8fdb\u7a0b\u5df2\u88ab\u6b7b\u9501\u5728&nbsp;&nbsp;lock&nbsp;\u8d44\u6e90\u4e0a\uff0c\u4e14\u8be5\u4e8b\u52a1\u5df2\u88ab\u9009\u4f5c\u6b7b\u9501\u727a\u7272\u54c1\u3002\u8bf7\u91cd\u65b0\u8fd0\u884c\u8be5\u4e8b\u52a1\u3002<\/span><\/div>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8fd9\u5c31\u662f\u4e0a\u9762\u7b2c\u56db\u8282\u4e2d\u4ecb\u7ecd\u7684<strong>\u9501\u76d1\u89c6\u5668<\/strong>\u5e72\u6d3b\u4e86\u3002<\/span><\/p>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\">b).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6309\u540c\u4e00\u987a\u5e8f\u8bbf\u95ee\u5bf9\u8c61\uff1a<\/span><\/strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u98a0\u5012\u4efb\u610f\u4e00\u6761<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e2d\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Update<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e0e<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SELECT<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8bed\u53e5\u7684\u987a\u5e8f\u3002\u4f8b\u5982\u4fee\u6539\u7b2c\u4e8c\u6761<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6210\u5982\u4e0b\uff1a<\/span><\/p>\n<div style=\"border-bottom:#cccccc 1px solid;border-left:#cccccc 1px solid;padding-bottom:5px;background-color:#f5f5f5;margin:5px 0px;padding-left:5px;padding-right:5px;font-family:'Courier New' !important;color:#000000;font-size:12px !important;overflow:auto;border-top:#cccccc 1px solid;border-right:#cccccc 1px solid;padding-top:5px;\" class=\"cnblogs_code\"><img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008080;font-size:12px !important;\">--<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008080;font-size:12px !important;\">Query2<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008080;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Begin<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Tran<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>&nbsp;&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">SELECT<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#808080;font-size:12px !important;\">*<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">FROM<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;Lock1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008080;font-size:12px !important;\">--<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008080;font-size:12px !important;\">\u5728Lock1\u4e0a\u7533\u8bf7S\u9501<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008080;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">WaitFor<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;Delay&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#ff0000;font-size:12px !important;\">'<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#ff0000;font-size:12px !important;\">00:01:00<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#ff0000;font-size:12px !important;\">'<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">;<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>&nbsp;&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Update<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;Lock2&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Set<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;C1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#808080;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">C1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#808080;font-size:12px !important;\">+<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;font-weight:bold;\">1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008080;font-size:12px !important;\">--<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008080;font-size:12px !important;\">Lock2:RID:X<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008080;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Rollback<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">Tran<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">;<\/span><\/div>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5f53\u7136\u8fd9\u6837\u4fee\u6539\u4e5f\u662f\u6709\u4ee3\u4ef7\u7684\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u7b2c\u4e00\u6761<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6267\u884c\u5b8c\u6bd5\u4e4b\u524d\uff0c\u7b2c\u4e8c\u6761<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e00\u76f4\u5904\u4e8e\u963b\u585e\u72b6\u6001\u3002\u5355\u72ec\u6267\u884c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Query1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6216<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Query2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9700\u8981\u7ea6<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5206\u949f\uff0c\u4f46\u5982\u679c\u5f00\u59cb\u6267\u884c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Query1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u65f6\uff0c\u9a6c\u4e0a\u540c\u65f6\u6267\u884c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Query2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u5219<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Query2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9700\u8981<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5206\u949f\u624d\u80fd\u6267\u884c\u5b8c\uff1b\u8fd9\u79cd\u6309\u987a\u5e8f\u8bf7\u6c42\u8d44\u6e90\u4ece\u4e00\u5b9a\u7a0b\u5ea6\u4e0a<strong>\u964d\u4f4e\u4e86\u5e76\u53d1\u6027\u3002<\/strong><\/span> <\/p>\n<p style=\"text-indent:0px;margin:10px auto;\">\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\">c).<span class=\"Apple-converted-space\">&nbsp;<\/span><strong>SELECT<\/strong><\/span><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8bed\u53e5\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">With(NoLock)<\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u63d0\u793a<\/span><\/strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1a\u9ed8\u8ba4\u60c5\u51b5\u4e0b<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SELECT<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8bed\u53e5\u4f1a\u5bf9\u67e5\u8be2\u5230\u7684\u8d44\u6e90\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5171\u4eab\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\u4e0e<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">X<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6392\u4ed6\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e0d\u517c\u5bb9\uff1b\u4f46\u52a0\u4e0a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">With(NoLock)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u540e\uff0c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SELECT<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e0d\u5bf9\u67e5\u8be2\u5230\u7684\u8d44\u6e90\u52a0\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6216\u8005\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Sch-S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\uff0c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Sch-S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\u53ef\u4ee5\u4e0e\u4efb\u4f55\u9501\u517c\u5bb9<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1b\u4ece\u800c\u53ef\u4ee5\u662f\u8fd9\u4e24\u6761<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL<\/span>\u53ef\u4ee5\u5e76\u53d1\u5730\u8bbf\u95ee\u540c\u4e00\u8d44\u6e90\u3002\u5f53\u7136\uff0c\u6b64\u65b9\u6cd5\u9002\u5408\u89e3\u51b3\u8bfb\u4e0e\u5199\u5e76\u53d1\u6b7b\u9501\u7684\u60c5\u51b5\uff0c\u4f46<strong>\u52a0With(NoLock)\u53ef\u80fd\u4f1a\u5bfc\u81f4\u810f\u8bfb\u3002<\/strong><\/p>\n<div style=\"border-bottom:#cccccc 1px solid;border-left:#cccccc 1px solid;padding-bottom:5px;background-color:#f5f5f5;margin:5px 0px;padding-left:5px;padding-right:5px;font-family:'Courier New' !important;color:#000000;font-size:12px !important;overflow:auto;border-top:#cccccc 1px solid;border-right:#cccccc 1px solid;padding-top:5px;\" class=\"cnblogs_code\"><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">SELECT<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#808080;font-size:12px !important;\">*<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">FROM<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;Lock2&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">WITH<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">(NOLock)<br \/>\n<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">SELECT<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#808080;font-size:12px !important;\">*<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">FROM<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;Lock1&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">WITH<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">(NOLock)<\/span><\/div>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;background-color:#d9d9d9;\" lang=\"EN-US\"><o:p><\/o:p><\/span><\/p>\n<p><span style=\"line-height:19px;\" lang=\"EN-US\">d).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4f7f\u7528\u8f83\u4f4e\u7684\u9694\u79bb\u7ea7\u522b\u3002<\/span><\/strong><span style=\"line-height:19px;\" lang=\"EN-US\">SQL Server 2000<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u652f\u6301\u56db\u79cd\u4e8b\u52a1\u5904\u7406\u9694\u79bb\u7ea7\u522b<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(TIL)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u5206\u522b\u4e3a\uff1a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">READ UNCOMMITTED<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u3001<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">READ COMMITTED<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u3001<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">REPEATABLE READ<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u3001<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SERIALIZABLE<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1b<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL Server 2005<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e2d\u589e\u52a0\u4e86<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SNAPSHOT TIL<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u3002<strong>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<\/strong><\/span><strong><span style=\"line-height:19px;\" lang=\"EN-US\">SQL Server<\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4f7f\u7528<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">READ COMMITTED TIL<\/span><\/strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u4e0a\u9762\u7684\u4e24\u6761<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u524d\u90fd\u52a0\u4e0a\u4e00\u53e5<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u6765<strong>\u964d\u4f4e<\/strong><\/span><strong><span style=\"line-height:19px;\" lang=\"EN-US\">TIL<\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4ee5\u907f\u514d\u6b7b\u9501<\/span><\/strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1b\u4e8b\u5b9e\u4e0a\uff0c\u8fd0\u884c\u5728<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">READ UNCOMMITTED TIL<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7684\u4e8b\u52a1\uff0c\u5176\u4e2d\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SELECT<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8bed\u53e5\u4e0d\u5bf9\u7ed3\u679c\u8d44\u6e90\u52a0\u9501\u6216\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Sch-S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\uff0c\u800c\u4e0d\u4f1a\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\uff1b\u4f46\u8fd8\u6709\u4e00\u70b9\u9700\u8981\u6ce8\u610f\u7684\u662f\uff1a<\/span><strong><span style=\"line-height:19px;\" lang=\"EN-US\">READ UNCOMMITTED TIL<\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5141\u8bb8\u810f\u8bfb<\/span><\/strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u867d\u7136\u52a0\u4e0a\u4e86\u964d\u4f4e<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">TIL<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7684\u8bed\u53e5\u540e\uff0c\u4e0a\u9762\u4e24\u6761<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5728\u6267\u884c\u8fc7\u7a0b\u4e2d\u4e0d\u4f1a\u62a5\u9519\uff0c\u4f46\u6267\u884c\u7ed3\u679c\u662f\u4e00\u4e2a\u8fd4\u56de<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u4e00\u4e2a\u8fd4\u56de<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u5373\u8bfb\u5230\u4e86\u810f\u6570\u636e\uff0c\u4e5f\u8bb8\u8fd9\u5e76\u4e0d\u662f\u6211\u4eec\u6240\u671f\u671b\u7684\u3002<\/span> <\/p>\n<p style=\"text-indent:0px;margin:10px auto;\">\n<p style=\"line-height:19px;text-indent:21pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\">e).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5728<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u524d\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SET LOCK_TIMEOUT timeout_period<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u5f53\u8bf7\u6c42\u9501\u8d85\u8fc7\u8bbe\u5b9a\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">timeout_period<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u65f6\u95f4\u540e\uff0c\u5c31\u4f1a\u7ec8\u6b62\u5f53\u524d<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7684\u6267\u884c\uff0c\u727a\u7272\u81ea\u5df1\uff0c\u6210\u5168\u522b\u4eba\u3002<\/span><\/p>\n<p style=\"line-height:19px;text-indent:21pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\">f).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4f7f\u7528\u57fa\u4e8e\u884c\u7248\u672c\u63a7\u5236\u7684\u9694\u79bb\u7ea7\u522b<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(SQL Server 2005<\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u652f\u6301<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><\/strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1a\u5f00\u542f\u4e0b\u9762\u7684\u9009\u9879\u540e\uff0c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SELECT<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e0d\u4f1a\u5bf9\u8bf7\u6c42\u7684\u8d44\u6e90\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\uff0c\u4e0d\u52a0\u9501\u6216\u8005\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Sch-S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\uff0c<strong>\u4ece\u800c\u5c06\u8bfb\u4e0e\u5199\u64cd\u4f5c\u4e4b\u95f4\u53d1\u751f\u7684\u6b7b\u9501\u51e0\u7387\u964d\u81f3\u6700\u4f4e\uff1b\u800c\u4e14\u4e0d\u4f1a\u53d1\u751f\u810f\u8bfb\u3002<\/strong>\u554a<\/span><\/p>\n<div style=\"border-bottom:#cccccc 1px solid;border-left:#cccccc 1px solid;padding-bottom:5px;background-color:#f5f5f5;margin:5px 0px;padding-left:5px;padding-right:5px;font-family:'Courier New' !important;color:#000000;font-size:12px !important;overflow:auto;border-top:#cccccc 1px solid;border-right:#cccccc 1px solid;padding-top:5px;\" class=\"cnblogs_code\"><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">SET<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;ALLOW_SNAPSHOT_ISOLATION&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">ON<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\"><br \/>\n<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">SET<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;READ_COMMITTED_SNAPSHOT&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">ON<\/span><\/div>\n<p style=\"line-height:19px;text-indent:21pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;background-color:#d9d9d9;\" lang=\"EN-US\"><o:p><\/o:p><\/span><\/p>\n<p><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span>g).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4f7f\u7528\u7ed1\u5b9a\u8fde\u63a5<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4f7f\u7528\u65b9\u6cd5\u89c1\u4e0b\u4e00\u4e2a\u793a\u4f8b\u3002<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span> <\/p>\n<p style=\"text-indent:0px;margin:10px auto;\">\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><o:p>&nbsp;<\/o:p><\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><strong><span style=\"line-height:19px;\" lang=\"EN-US\">5.2<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7a0b\u5e8f\u6b7b\u9501<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(SQL<\/span><\/strong><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u963b\u585e<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<o:p><\/o:p><\/span><\/strong><\/p>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u770b\u4e00\u4e2a\u4f8b\u5b50\uff1a<a style=\"color:#4371a6;\" href=\"http:\/\/www.cnblogs.com\/kaima\/archive\/2008\/04\/24\/1167550.html\">\u4e00\u4e2a\u5178\u578b\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u4e8b\u52a1\u6b7b\u9501\u5206\u6790<\/a><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u6309\u7167\u6211\u81ea\u5df1\u7684\u7406\u89e3\uff0c\u6211\u89c9\u5f97\u8fd9\u5e94\u8be5\u7b97\u662f<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">C#<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7a0b\u5e8f\u4e2d\u51fa\u73b0\u6b7b\u9501\uff0c\u800c\u4e0d\u662f\u6570\u636e\u5e93\u4e2d\u7684\u6b7b\u9501\uff1b\u4e0b\u9762\u7684\u4ee3\u7801\u6a21\u62df\u4e86\u8be5\u6587\u4e2d\u5bf9\u6570\u636e\u5e93\u7684\u64cd\u4f5c\u8fc7\u7a0b\uff1a<\/span><\/p>\n<div style=\"border-bottom:#cccccc 1px solid;border-left:#cccccc 1px solid;padding-bottom:5px;background-color:#f5f5f5;margin:5px 0px;padding-left:5px;padding-right:5px;font-family:'Courier New' !important;color:#000000;font-size:12px !important;overflow:auto;border-top:#cccccc 1px solid;border-right:#cccccc 1px solid;padding-top:5px;\" class=\"cnblogs_code\">\n<div style=\"background-color:#f5f5f5;margin-top:5px;\" class=\"cnblogs_code_toolbar\"><span style=\"line-height:1.5 !important;padding-right:5px;font-family:'Courier New' !important;font-size:12px !important;\" class=\"cnblogs_code_copy\"><a style=\"border-bottom:medium none;border-left:medium none;background-color:#f5f5f5;color:#4371a6;border-top:medium none;border-right:medium none;\" title=\"\u590d\u5236\u4ee3\u7801\" onclick=\"copyCnblogsCode(this)\" href=\"javascript:void(0);\"><img decoding=\"async\" style=\"border-bottom:medium none;border-left:medium none;background-color:#f5f5f5;border-top:medium none;border-right:medium none;\" alt=\"\u590d\u5236\u4ee3\u7801\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" \/><\/a><\/span><\/div>\n<p><img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008000;font-size:12px !important;\">\/\/<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008000;font-size:12px !important;\">\u7565\u53bb\u7684\u65e0\u5173\u7684code<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008000;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">SqlConnection&nbsp;conn&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">new<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;SqlConnection(connectionString);<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>conn.Open();<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>SqlTransaction&nbsp;tran&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;conn.BeginTransaction();<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">string<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;sql1&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">\"<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">Update&nbsp;Lock1&nbsp;SET&nbsp;C1=C1+1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">\"<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">;<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">string<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;sql2&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">\"<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">SELECT&nbsp;*&nbsp;FROM&nbsp;Lock1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">\"<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">;<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>ExecuteNonQuery(tran,&nbsp;sql1);&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008000;font-size:12px !important;\">\/\/<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008000;font-size:12px !important;\">\u4f7f\u7528\u4e8b\u52a1:\u4e8b\u52a1\u4e2dLock\u4e86Table<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008000;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">ExecuteNonQuery(<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">null<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">,&nbsp;sql2);&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008000;font-size:12px !important;\">\/\/<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008000;font-size:12px !important;\">\u65b0\u5f00\u4e00\u4e2aconnection\u6765\u8bfb\u53d6Table<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008000;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">public<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">static<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">void<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;ExecuteNonQuery(SqlTransaction&nbsp;tran,&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">string<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;sql)<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" id=\"Codehighlighter1_383_776_Open_Image\" onclick=\"code_collapse_toggle(this);\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedBlockStart.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;font-size:12px !important;\" id=\"Codehighlighter1_383_776_Open_Text\"><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">{<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;SqlCommand&nbsp;cmd&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">new<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;SqlCommand(sql);<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">if<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;(tran&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">!=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">null<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">)<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" id=\"Codehighlighter1_453_565_Open_Image\" onclick=\"code_collapse_toggle(this);\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedSubBlockStart.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;font-size:12px !important;\" id=\"Codehighlighter1_453_565_Open_Text\"><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">{<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmd.Connection&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;tran.Connection;<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmd.Transaction&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;tran;<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmd.ExecuteNonQuery();<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedSubBlockEnd.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;}<\/span><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">else<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" id=\"Codehighlighter1_579_774_Open_Image\" onclick=\"code_collapse_toggle(this);\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedSubBlockStart.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;font-size:12px !important;\" id=\"Codehighlighter1_579_774_Open_Text\"><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">{<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">using<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;(SqlConnection&nbsp;conn&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">new<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;SqlConnection(connectionString))<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" id=\"Codehighlighter1_662_768_Open_Image\" onclick=\"code_collapse_toggle(this);\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedSubBlockStart.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;font-size:12px !important;\" id=\"Codehighlighter1_662_768_Open_Text\"><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">{<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conn.Open();<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmd.Connection&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;conn;<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmd.ExecuteNonQuery();<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedSubBlockEnd.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/span><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedSubBlockEnd.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;}<\/span><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedBlockEnd.gif\" \/>}<\/span><\/span> <\/p>\n<div style=\"background-color:#f5f5f5;margin-top:5px;\" class=\"cnblogs_code_toolbar\"><span style=\"line-height:1.5 !important;padding-right:5px;font-family:'Courier New' !important;font-size:12px !important;\" class=\"cnblogs_code_copy\"><a style=\"border-bottom:medium none;border-left:medium none;background-color:#f5f5f5;color:#4371a6;border-top:medium none;border-right:medium none;\" title=\"\u590d\u5236\u4ee3\u7801\" onclick=\"copyCnblogsCode(this)\" href=\"javascript:void(0);\"><img decoding=\"async\" style=\"border-bottom:medium none;border-left:medium none;background-color:#f5f5f5;border-top:medium none;border-right:medium none;\" alt=\"\u590d\u5236\u4ee3\u7801\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" \/><\/a><\/span><\/div>\n<\/div>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6267\u884c\u5230<\/span><span style=\"line-height:22px;font-family:Consolas;font-size:11pt;\" lang=\"EN-US\">ExecuteNonQuery(<span style=\"line-height:22px;color:blue;\">null<\/span>, sql2)<\/span><span style=\"line-height:22px;font-family:\u5b8b\u4f53;font-size:11pt;\">\u65f6\u629b\u51fa<\/span><span style=\"line-height:22px;font-family:Consolas;font-size:11pt;\" lang=\"EN-US\">SQL<\/span><span style=\"line-height:22px;font-family:\u5b8b\u4f53;font-size:11pt;\">\u6267\u884c\u8d85\u65f6\u7684\u5f02\u5e38\uff0c\u4e0b\u56fe\u4ece\u6570\u636e\u5e93\u7684\u89d2\u5ea6\u6765\u770b\u8be5\u95ee\u9898\uff1a<\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a id=\"ematt:236\" href=\"\/notes\/content\/uploadfile\/201411\/771e1416026594.jpg\" target=\"_blank\"><img decoding=\"async\" border=\"0\" alt=\"\u70b9\u51fb\u67e5\u770b\u539f\u56fe\" src=\"\/notes\/content\/uploadfile\/201411\/771e1416026594.jpg\" \/><\/a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u4ee3\u7801\u4ece\u4e0a\u5f80\u4e0b\u6267\u884c\uff0c\u4f1a\u8bdd<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6301\u6709\u4e86\u8868<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Lock1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">X<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\uff0c\u4e14\u4e8b\u52a1\u6ca1\u6709\u7ed3\u675f\uff0c\u56de\u8bdd<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5c31\u4e00\u76f4\u6301\u6709<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">X<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\u4e0d\u91ca\u653e\uff1b\u800c\u4f1a\u8bdd<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6267\u884c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">select<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u64cd\u4f5c\uff0c\u8bf7\u6c42\u5728\u8868<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Lock1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e0a\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\uff0c\u4f46<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\u4e0e<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">X<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\u662f\u4e0d\u517c\u5bb9\u7684\uff0c\u6240\u4ee5\u56de\u8bdd<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">2<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7684\u88ab\u963b\u585e\u7b49\u5f85\uff0c\u4e0d\u5728\u7b49\u5f85\u4e2d\uff0c\u5c31\u5728\u7b49\u5f85\u4e2d\u83b7\u5f97\u8d44\u6e90\uff0c\u5c31\u5728\u7b49\u5f85\u4e2d\u8d85\u65f6\u3002\u3002\u3002\u4ece\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0c\u91cc\u9762\u5e76\u6ca1\u6709\u51fa\u73b0\u6b7b\u9501\uff0c\u800c\u53ea\u662f<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SELECT<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u64cd\u4f5c\u88ab\u963b\u585e\u4e86\u3002\u4e5f\u6b63\u56e0\u4e3a\u4e0d\u662f\u6570\u636e\u5e93\u6b7b\u9501\uff0c\u6240\u4ee5<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SQL Server<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7684\u9501\u76d1\u89c6\u5668\u65e0\u6cd5\u68c0\u6d4b\u5230\u6b7b\u9501\u3002<\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6211\u4eec\u518d\u4ece<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">C#<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7a0b\u5e8f\u7684\u89d2\u5ea6\u6765\u770b\u8be5\u95ee\u9898\uff1a<\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><o:p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a id=\"ematt:237\" href=\"\/notes\/content\/uploadfile\/201411\/8e771416026594.jpg\" target=\"_blank\"><img decoding=\"async\" border=\"0\" alt=\"\u70b9\u51fb\u67e5\u770b\u539f\u56fe\" src=\"\/notes\/content\/uploadfile\/201411\/8e771416026594.jpg\" \/><\/a>&nbsp;<\/o:p><\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span>C#<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u7a0b\u5e8f\u6301\u6709\u4e86\u8868<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Lock1<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e0a\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">X<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\uff0c\u540c\u65f6\u5f00\u4e86\u53e6\u4e00\u4e2a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SqlConnection<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8fd8\u60f3\u5728\u8be5\u8868\u4e0a\u8bf7\u6c42\u4e00\u628a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\uff0c\u56fe\u4e2d\u5df2\u7ecf\u6784\u6210\u4e86\u73af\u8def\uff1b\u592a\u8d2a\u5fc3\u4e86\uff0c\u7ed3\u679c\u81ea\u5df1\u628a\u81ea\u5df1\u7ed9\u9501\u6b7b\u4e86\u3002\u3002\u3002<\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u867d\u7136\u8fd9\u4e0d\u662f\u4e00\u4e2a\u6570\u636e\u5e93\u6b7b\u9501\uff0c\u4f46\u5374\u662f\u56e0\u4e3a\u6570\u636e\u5e93\u8d44\u6e90\u800c\u5bfc\u81f4\u7684\u6b7b\u9501\uff0c\u4e0a\u4f8b\u4e2d\u63d0\u5230\u7684\u89e3\u51b3\u6b7b\u9501\u7684\u65b9\u6cd5\u5728\u8fd9\u91cc\u4e5f\u57fa\u672c\u9002\u7528\uff0c\u4e3b\u8981\u662f\u907f\u514d\u8bfb\u64cd\u4f5c\u88ab\u963b\u585e\uff0c\u89e3\u51b3\u65b9\u6cd5\u5982\u4e0b\uff1a<\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span>a).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u628a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SELECT<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u653e\u5728<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Update<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8bed\u53e5\u524d\uff1a<\/span><\/strong><span style=\"line-height:19px;\" lang=\"EN-US\">SELECT<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e0d\u5728\u4e8b\u52a1\u4e2d\uff0c\u4e14\u6267\u884c\u5b8c\u6bd5\u4f1a\u91ca\u653e<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">S<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\uff1b<br \/>\n<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span>b).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u628a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SELECT<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e5f\u653e\u52a0\u5165\u5230\u4e8b\u52a1\u4e2d\uff1a<\/span><\/strong><span style=\"line-height:22px;font-family:Consolas;font-size:11pt;\" lang=\"EN-US\">ExecuteNonQuery(tran, sql2);<br \/>\n<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span>c).<span class=\"Apple-converted-space\">&nbsp;<\/span><strong>SELECT<\/strong><\/span><strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">With(NOLock)<\/span><\/strong><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\"><strong>\u63d0\u793a\uff1a<\/strong>\u53ef\u80fd\u4ea7\u751f\u810f\u8bfb\uff1b<br \/>\n<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span>d).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\"><strong>\u964d\u4f4e\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\uff1a<\/strong><\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SELECT<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8bed\u53e5\u524d\u52a0<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1b\u540c\u4e0a\uff0c\u53ef\u80fd\u4ea7\u751f\u810f\u8bfb\uff1b<br \/>\n<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span>e).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\"><strong>\u4f7f\u7528\u57fa\u4e8e\u884c\u7248\u672c\u63a7\u5236\u7684\u9694\u79bb\u7ea7\u522b<\/strong>\uff08\u540c\u4e0a\u4f8b\uff09\u3002<br \/>\n<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span>g).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\"><strong>\u4f7f\u7528\u7ed1\u5b9a\u8fde\u63a5\uff1a<\/strong>\u53d6\u5f97\u4e8b\u52a1\u6240\u5728\u4f1a\u8bdd\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">token<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff0c\u7136\u540e\u4f20\u5165\u65b0\u5f00\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">connection<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e2d\uff1b\u6267\u884c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">EXEC sp_bindsession @Token<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u540e\u7ed1\u5b9a\u4e86\u8fde\u63a5\uff0c\u6700\u540e\u6267\u884c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">exec sp_bindsession null;<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6765\u53d6\u6d88\u7ed1\u5b9a\uff1b\u6700\u540e\u9700\u8981\u6ce8\u610f\u7684\u56db\u70b9\u662f\uff1a<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(1).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4f7f\u7528\u4e86\u7ed1\u5b9a\u8fde\u63a5\u7684\u591a\u4e2a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">connection<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5171\u4eab\u540c\u4e00\u4e2a\u4e8b\u52a1\u548c\u76f8\u540c\u7684\u9501\uff0c\u4f46\u5404\u81ea\u4fdd\u7559\u81ea\u5df1\u7684\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\uff1b<br \/>\n&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(2).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5982\u679c\u5728<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">sql3<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5b57\u7b26\u4e32\u7684\u201c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">exec sp_bindsession null<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u201d\u6362\u6210\u201c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">commit tran<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u201d\u6216\u8005\u201c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">rollback tran<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u201d\uff0c\u5219\u4f1a\u63d0\u4ea4\u6574\u4e2a\u4e8b\u52a1\uff0c\u6700\u540e\u4e00\u884c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">C#<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4ee3\u7801<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">tran.Commit()<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5c31\u53ef\u4ee5\u4e0d\u7528\u6267\u884c\u4e86<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6267\u884c\u4f1a\u62a5\u9519\uff0c\u56e0\u4e3a\u4e8b\u52a1\u5df2\u7ecf\u7ed3\u675f\u4e86<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">-,-)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u3002<br \/>\n&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(3).<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5f00\u542f\u4e8b\u52a1<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(begin tran)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u540e\uff0c\u624d\u53ef\u4ee5\u8c03\u7528<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">exec sp_getbindtoken @Token out<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6765\u53d6\u5f97<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">Token<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1b\u5982\u679c\u4e0d\u60f3\u518d\u65b0\u5f00\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">connection<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e2d\u7ed3\u675f\u6389\u539f\u6709\u7684\u4e8b\u52a1\uff0c\u5219\u5728\u8fd9\u4e2a<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">connection close<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e4b\u524d\uff0c\u5fc5\u987b\u6267\u884c\u201c<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">exec sp_bindsession null<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u201d\u6765\u53d6\u6d88\u7ed1\u5b9a\u8fde\u63a5\uff0c\u6216\u8005\u5728\u65b0\u5f00\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">connectoin close<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e4b\u524d\u5148\u7ed3\u675f\u6389\u4e8b\u52a1<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(commit\/tran)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u3002<br \/>\n&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(4). (Sql server 2005<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8054\u673a\u4e1b\u4e66<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u540e\u7eed\u7248\u672c\u7684<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span class=\"Apple-converted-space\">&nbsp;<\/span>Microsoft SQL Server<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5c06\u5220\u9664\u8be5\u529f\u80fd\u3002\u8bf7\u907f\u514d\u5728\u65b0\u7684\u5f00\u53d1\u5de5\u4f5c\u4e2d\u4f7f\u7528\u8be5\u529f\u80fd\uff0c\u5e76\u7740\u624b\u4fee\u6539\u5f53\u524d\u8fd8\u5728\u4f7f\u7528\u8be5\u529f\u80fd\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/span><span class=\"Apple-converted-space\">&nbsp;<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8bf7\u6539\u7528\u591a\u4e2a\u6d3b\u52a8\u7ed3\u679c\u96c6<\/span><span style=\"line-height:19px;\" lang=\"EN-US\"><span class=\"Apple-converted-space\">&nbsp;<\/span>(MARS)<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6216\u5206\u5e03\u5f0f\u4e8b\u52a1\u3002<\/span><\/p>\n<div style=\"border-bottom:#cccccc 1px solid;border-left:#cccccc 1px solid;padding-bottom:5px;background-color:#f5f5f5;margin:5px 0px;padding-left:5px;padding-right:5px;font-family:'Courier New' !important;color:#000000;font-size:12px !important;overflow:auto;border-top:#cccccc 1px solid;border-right:#cccccc 1px solid;padding-top:5px;\" class=\"cnblogs_code\">\n<div style=\"background-color:#f5f5f5;margin-top:5px;\" class=\"cnblogs_code_toolbar\"><span style=\"line-height:1.5 !important;padding-right:5px;font-family:'Courier New' !important;font-size:12px !important;\" class=\"cnblogs_code_copy\"><a style=\"border-bottom:medium none;border-left:medium none;background-color:#f5f5f5;color:#4371a6;border-top:medium none;border-right:medium none;\" title=\"\u590d\u5236\u4ee3\u7801\" onclick=\"copyCnblogsCode(this)\" href=\"javascript:void(0);\"><img decoding=\"async\" style=\"border-bottom:medium none;border-left:medium none;background-color:#f5f5f5;border-top:medium none;border-right:medium none;\" alt=\"\u590d\u5236\u4ee3\u7801\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" \/><\/a><\/span><\/div>\n<p><img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">tran&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;connection.BeginTransaction();<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">string<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;sql1&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">\"<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">Update&nbsp;Lock1&nbsp;SET&nbsp;C1=C1+1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">\"<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">;<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>ExecuteNonQuery(tran,&nbsp;sql1);&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008000;font-size:12px !important;\">\/\/<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008000;font-size:12px !important;\">\u4f7f\u7528\u4e8b\u52a1:\u4e8b\u52a1\u4e2dLock\u4e86\u6d4b\u8bd5\u8868Lock1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008000;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">string<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;sql2&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">@\"<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">DECLARE&nbsp;@Token&nbsp;varchar(255);<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>exec&nbsp;sp_getbindtoken&nbsp;@Token&nbsp;out;<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>SELECT&nbsp;@Token;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">\"<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">;<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">string<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;token&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;ExecuteScalar(tran,&nbsp;sql2).ToString();<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">string<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;sql3&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">\"<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">EXEC&nbsp;sp_bindsession&nbsp;@Token;Update&nbsp;Lock1&nbsp;SET&nbsp;C1=C1+1;exec&nbsp;sp_bindsession&nbsp;null;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">\"<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">;<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>SqlParameter&nbsp;parameter&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">new<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;SqlParameter(<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">\"<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">@Token<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#800000;font-size:12px !important;\">\"<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">,&nbsp;SqlDbType.VarChar);<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>parameter.Value&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">=<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">&nbsp;token;<br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>ExecuteNonQuery(<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#0000ff;font-size:12px !important;\">null<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">,&nbsp;sql3,&nbsp;parameter);&nbsp;<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008000;font-size:12px !important;\">\/\/<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008000;font-size:12px !important;\">\u65b0\u5f00\u4e00\u4e2aconnection\u6765\u64cd\u4f5c\u6d4b\u8bd5\u8868Lock1<\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#008000;font-size:12px !important;\"><br \/>\n<img decoding=\"async\" style=\"border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"line-height:1.5 !important;font-family:'Courier New' !important;color:#000000;font-size:12px !important;\">tran.Commit();<\/span> <\/p>\n<div style=\"background-color:#f5f5f5;margin-top:5px;\" class=\"cnblogs_code_toolbar\"><span style=\"line-height:1.5 !important;padding-right:5px;font-family:'Courier New' !important;font-size:12px !important;\" class=\"cnblogs_code_copy\"><a style=\"border-bottom:medium none;border-left:medium none;background-color:#f5f5f5;color:#4371a6;border-top:medium none;border-right:medium none;\" title=\"\u590d\u5236\u4ee3\u7801\" onclick=\"copyCnblogsCode(this)\" href=\"javascript:void(0);\"><img decoding=\"async\" style=\"border-bottom:medium none;border-left:medium none;background-color:#f5f5f5;border-top:medium none;border-right:medium none;\" alt=\"\u590d\u5236\u4ee3\u7801\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" \/><\/a><\/span><\/div>\n<\/div>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">&nbsp;<\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">&nbsp;<\/p>\n<p style=\"line-height:19px;text-indent:21pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\">\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><strong><span style=\"line-height:24px;font-family:\u5b8b\u4f53;font-size:12pt;\">\u9644\uff1a\u9501\u517c\u5bb9\u6027<\/span><\/strong><strong><span style=\"line-height:24px;font-size:12pt;\" lang=\"EN-US\">(FROM SQL Server 2005<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/strong><strong><span style=\"line-height:24px;font-family:\u5b8b\u4f53;font-size:12pt;\">\u8054\u673a\u4e1b\u4e66<\/span><\/strong><strong><span style=\"line-height:24px;font-size:12pt;\" lang=\"EN-US\">)<o:p><\/o:p><\/span><\/strong><\/p>\n<p style=\"line-height:19px;text-indent:21.75pt;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u9501\u517c\u5bb9\u6027\u63a7\u5236\u591a\u4e2a\u4e8b\u52a1\u80fd\u5426\u540c\u65f6\u83b7\u53d6\u540c\u4e00\u8d44\u6e90\u4e0a\u7684\u9501\u3002\u5982\u679c\u8d44\u6e90\u5df2\u88ab\u53e6\u4e00\u4e8b\u52a1\u9501\u5b9a\uff0c\u5219\u4ec5\u5f53\u8bf7\u6c42\u9501\u7684\u6a21\u5f0f\u4e0e\u73b0\u6709\u9501\u7684\u6a21\u5f0f\u76f8\u517c\u5bb9\u65f6\uff0c\u624d\u4f1a\u6388\u4e88\u65b0\u7684\u9501\u8bf7\u6c42\u3002\u5982\u679c\u8bf7\u6c42\u9501\u7684\u6a21\u5f0f\u4e0e\u73b0\u6709\u9501\u7684\u6a21\u5f0f\u4e0d\u517c\u5bb9\uff0c\u5219\u8bf7\u6c42\u65b0\u9501\u7684\u4e8b\u52a1\u5c06\u7b49\u5f85\u91ca\u653e\u73b0\u6709\u9501\u6216\u7b49\u5f85\u9501\u8d85\u65f6\u95f4\u9694\u8fc7\u671f\u3002<br \/>\n<a id=\"ematt:238\" href=\"\/notes\/content\/uploadfile\/201411\/49e61416026594.jpg\" target=\"_blank\"><img decoding=\"async\" border=\"0\" alt=\"\u70b9\u51fb\u67e5\u770b\u539f\u56fe\" src=\"\/notes\/content\/uploadfile\/201411\/49e61416026594.jpg\" \/><\/a><\/span><\/p>\n<p><\/span><\/div>\n<div style=\"text-transform:none;text-indent:0px;letter-spacing:normal;display:block;font:13px\/20px georgia, verdana, Arial, helvetica, sans-seriff;white-space:normal;color:#4b4b4b;word-spacing:0px;-webkit-text-stroke-width:0px;\" id=\"MySignature\">&nbsp;<\/div>\n<div style=\"text-transform:none;text-indent:0px;letter-spacing:normal;display:block;font:13px\/20px georgia, verdana, Arial, helvetica, sans-seriff;white-space:normal;color:#4b4b4b;word-spacing:0px;-webkit-text-stroke-width:0px;\">\u6587\u7ae0\u6765\u6e90\uff1a <a href=\"http:\/\/www.cnblogs.com\/happyhippy\/archive\/2008\/11\/14\/1333922.html\">http:\/\/www.cnblogs.com\/happyhippy\/archive\/2008\/11\/14\/1333922.html<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<div style=\"text-transform:none;text-indent:0px;letter-spacing:normal;font:13px\/20px georgia, verdana, Arial, helvetica, sans-seriff;white-space:normal;margin-bottom:20px;color:#4b4b4b;word-spacing:0px;-webkit-text-stroke-width:0px;\" id=\"cnblogs_post_body\">\n<p style=\"text-indent:0px;margin:10px auto;\"><span class=\"Apple-converted-space\">&nbsp;<\/span><strong><span style=\"line-height:24px;font-size:12pt;\" lang=\"EN-US\">1.<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/strong><strong><span style=\"line-height:24px;font-family:\u5b8b\u4f53;font-size:12pt;\">\u6b7b\u9501\u539f\u7406<\/span><\/strong><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7684\u5b9a\u4e49\uff1a\u6b7b\u9501\u662f\u6307\u5728\u4e00\u7ec4\u8fdb\u7a0b\u4e2d\u7684\u5404\u4e2a\u8fdb\u7a0b\u5747\u5360\u6709\u4e0d\u4f1a\u91ca\u653e\u7684\u8d44\u6e90\uff0c\u4f46\u56e0\u4e92\u76f8\u7533\u8bf7\u88ab\u5176\u4ed6\u8fdb\u7a0b\u6240\u7ad9\u7528\u4e0d\u4f1a\u91ca\u653e\u7684\u8d44\u6e90\u800c\u5904\u4e8e\u7684\u4e00\u79cd\u6c38\u4e45\u7b49\u5f85\u72b6\u6001\u3002<\/span><\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><span style=\"line-height:19px;\" lang=\"EN-US\"><span style=\"line-height:19px;\">&nbsp;&nbsp;&nbsp;<span class=\"Apple-converted-space\">&nbsp;<\/span><\/span><\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u6b7b\u9501\u7684\u56db\u4e2a\u5fc5\u8981\u6761\u4ef6\uff1a<br \/>\n<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u4e92\u65a5\u6761\u4ef6<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(Mutual exclusion)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1a\u8d44\u6e90\u4e0d\u80fd\u88ab\u5171\u4eab\uff0c\u53ea\u80fd\u7531\u4e00\u4e2a\u8fdb\u7a0b\u4f7f\u7528\u3002<br \/>\n<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u8bf7\u6c42\u4e0e\u4fdd\u6301\u6761\u4ef6<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(Hold and wait)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1a\u5df2\u7ecf\u5f97\u5230\u8d44\u6e90\u7684\u8fdb\u7a0b\u53ef\u4ee5\u518d\u6b21\u7533\u8bf7\u65b0\u7684\u8d44\u6e90\u3002<br \/>\n<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u975e\u5265\u593a\u6761\u4ef6<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(No pre-emption)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1a\u5df2\u7ecf\u5206\u914d\u7684\u8d44\u6e90\u4e0d\u80fd\u4ece\u76f8\u5e94\u7684\u8fdb\u7a0b\u4e2d\u88ab\u5f3a\u5236\u5730\u5265\u593a\u3002<br \/>\n<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\u5faa\u73af\u7b49\u5f85\u6761\u4ef6<\/span><span style=\"line-height:19px;\" lang=\"EN-US\">(Circular wait)<\/span><span style=\"line-height:19px;font-family:\u5b8b\u4f53;\">\uff1a\u7cfb\u7edf...<\/span><\/p>\n<p><span style=\"line-height:19px;\" lang=\"EN-US\"> <\/p>\n<p style=\"line-height:19px;text-indent:0px;margin:10px auto;font-size:13px;\" class=\"MsoNormal\"><\/span><\/p>\n<\/div>\n<p> <a href=\"https:\/\/www.xiaobo.li\/notes\/archives\/372\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[288],"tags":[172],"class_list":["post-372","post","type-post","status-publish","format-standard","hentry","category-db","tag-sqlserver"],"_links":{"self":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/comments?post=372"}],"version-history":[{"count":0,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/372\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/media?parent=372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/categories?post=372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/tags?post=372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}