{"id":5977,"date":"2024-11-14T13:33:59","date_gmt":"2024-11-14T05:33:59","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5977\/"},"modified":"2024-11-14T13:33:59","modified_gmt":"2024-11-14T05:33:59","slug":"sql-rowcount%e4%bb%80%e4%b9%88%e6%84%8f%e6%80%9d","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5977\/","title":{"rendered":"sql rowcount\u4ec0\u4e48\u610f\u601d"},"content":{"rendered":"<blockquote><p>\n  sql \u4e2d rowcount \u662f\u4e00\u4e2a\u7cfb\u7edf\u53d8\u91cf\uff0c\u8fd4\u56de\u4e0a\u4e00\u4e2a transact-sql \u8bed\u53e5\u6240\u5f71\u54cd\u7684\u884c\u6570\uff0c\u53ef\u7528\u4e8e\u68c0\u67e5\u8bed\u53e5\u6267\u884c\u60c5\u51b5\uff0c\u8ba1\u6570\u7ed3\u679c\u96c6\u884c\u6570\uff0c\u6216\u63a7\u5236\u5faa\u73af\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/12\/2024061203421710894.jpg\" class=\"aligncenter\" title=\"sql rowcount\u4ec0\u4e48\u610f\u601d\u63d2\u56fe\" alt=\"sql rowcount\u4ec0\u4e48\u610f\u601d\u63d2\u56fe\" \/><\/p>\n<p><strong>SQL ROWCOUNT \u542b\u4e49<\/strong><\/p>\n<p>\u5728 SQL \u4e2d\uff0cROWCOUNT \u662f\u4e00\u4e2a\u7cfb\u7edf\u53d8\u91cf\uff0c\u8868\u793a\u4e0a\u4e00\u4e2a Transact-SQL \u8bed\u53e5\u6240\u53d7\u5f71\u54cd\u7684\u884c\u6570\u3002<\/p>\n<p><strong>\u7528\u9014<\/strong><\/p>\n<p>ROWCOUNT \u53ef\u7528\u4e8e\uff1a<\/p>\n<ul>\n<li>\u786e\u5b9a Transact-SQL \u8bed\u53e5\u662f\u5426\u6210\u529f\u66f4\u65b0\u3001\u63d2\u5165\u6216\u5220\u9664\u4e86\u6570\u636e\u3002<\/li>\n<li>\u8ba1\u6570\u7ed3\u679c\u96c6\u4e2d\u7684\u884c\u6570\u3002<\/li>\n<li>\u63a7\u5236\u5faa\u73af\u6216\u5faa\u73af\u6761\u4ef6\u3002<\/li>\n<\/ul>\n<p><strong>\u8bed\u6cd5<\/strong><\/p>\n<pre>SELECT @@ROWCOUNT<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<pre>-- \u66f4\u65b0\u8868\nUPDATE myTable SET name = 'John Doe' WHERE id = 1;\n\n-- \u68c0\u67e5\u53d7\u5f71\u54cd\u884c\u6570\nSELECT @@ROWCOUNT;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u7ed3\u679c\uff1a<\/strong><\/p>\n<p>\u4e0a\u9762\u7684\u793a\u4f8b\u5c06\u66f4\u65b0\u4e00\u884c\uff0c\u56e0\u6b64 ROWCOUNT \u7684\u503c\u5c06\u4e3a 1\u3002<\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<ul>\n<li>ROWCOUNT \u4ec5\u9002\u7528\u4e8e\u6570\u636e\u64cd\u4f5c\u8bed\u53e5 (DML)\uff0c\u5982 INSERT\u3001UPDATE \u548c DELETE\u3002\u5bf9\u4e8e DDL \u8bed\u53e5 (\u5982 CREATE TABLE \u6216 ALTER TABLE)\uff0c\u5b83\u8fd4\u56de 0\u3002<\/li>\n<li>ROWCOUNT \u5728\u8bed\u53e5\u6267\u884c\u540e\u7acb\u5373\u63d0\u4f9b\u53d7\u5f71\u54cd\u7684\u884c\u6570\u3002\u5b83\u4e0d\u4f1a\u66f4\u65b0\u540e\u7eed\u8bed\u53e5\u3002<\/li>\n<li>@@ROWCOUNT \u662f\u4e00\u4e2a\u4e34\u65f6\u503c\uff0c\u5b83\u4f1a\u5728\u6267\u884c\u4e0b\u4e00\u4e2a\u8bed\u53e5\u65f6\u91cd\u7f6e\u4e3a 0\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fsql rowcount\u4ec0\u4e48\u610f\u601d\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>sql \u4e2d rowcount \u662f\u4e00\u4e2a\u7cfb\u7edf\u53d8\u91cf\uff0c\u8fd4\u56de\u4e0a\u4e00\u4e2a transact-sql \u8bed\u53e5\u6240\u5f71\u54cd\u7684\u884c\u6570\uff0c\u53ef\u7528\u4e8e\u68c0\u67e5\u8bed\u53e5\u6267\u884c\u60c5\u51b5\uff0c\u8ba1\u6570\u7ed3\u679c\u96c6\u884c\u6570\uff0c\u6216\u63a7\u5236\u5faa\u73af\u3002 SQL ROWCOUNT \u542b\u4e49 \u5728 SQL \u4e2d\uff0cROWCOUNT \u662f\u4e00\u4e2a\u7cfb\u7edf\u53d8\u91cf\uff0c\u8868\u793a\u4e0a\u4e00\u4e2a Transact-SQL \u8bed\u53e5\u6240\u53d7\u5f71\u54cd\u7684\u884c\u6570\u3002 \u7528\u9014 ROWCOUNT \u53ef\u7528\u4e8e\uff1a \u786e\u5b9a Transact-SQL \u8bed\u53e5\u662f\u5426\u6210\u529f\u66f4\u65b0\u3001\u63d2\u5165\u6216\u5220\u9664\u4e86\u6570\u636e\u3002 \u8ba1\u6570\u7ed3\u679c\u96c6\u4e2d\u7684\u884c\u6570\u3002 \u63a7\u5236\u5faa\u73af\u6216\u5faa\u73af\u6761\u4ef6\u3002 \u8bed\u6cd5 SELECT @@ROWCOUNT \u767b\u5f55\u540e\u590d\u5236 \u793a\u4f8b &#8212; \u66f4\u65b0\u8868 UPDATE myTable SET name = &#8216;John Doe&#8217; WHERE id = 1; &#8212; \u68c0\u67e5\u53d7\u5f71\u54cd\u884c\u6570 SELECT @@ROWCOUNT; \u767b\u5f55\u540e\u590d\u5236 \u7ed3\u679c\uff1a \u4e0a\u9762\u7684\u793a\u4f8b\u5c06\u66f4\u65b0\u4e00\u884c\uff0c\u56e0\u6b64 ROWCOUNT \u7684\u503c\u5c06\u4e3a 1\u3002 \u6ce8\u610f\u4e8b\u9879 ROWCOUNT \u4ec5\u9002\u7528\u4e8e\u6570\u636e\u64cd\u4f5c\u8bed\u53e5 (DML)\uff0c\u5982 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5977","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5977","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=5977"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5977\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5977"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5977"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5977"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}