{"id":2093,"date":"2013-06-25T04:54:10","date_gmt":"2013-06-25T04:54:10","guid":{"rendered":"http:\/\/www.withdata.com\/ad\/?p=2093"},"modified":"2017-04-20T10:54:56","modified_gmt":"2017-04-20T10:54:56","slug":"the-sql-server-equivalent-for-the-mysql-limit","status":"publish","type":"post","link":"https:\/\/www.withdata.com\/blog\/sql-server\/the-sql-server-equivalent-for-the-mysql-limit.html","title":{"rendered":"The SQL Server equivalent for the MySQL Limit"},"content":{"rendered":"<p>In MySQL, you can use &#8220;Limit n,m&#8221;, like this:<\/p>\n<pre>select *\r\nfrom sometable\r\norder by name\r\nlimit 20,10<\/pre>\n<p>And in SQL Server, use this query:<\/p>\n<pre>SELECT *\r\nFROM\r\n(\r\n      SELECT *,\r\n        ROW_NUMBER() OVER (ORDER BY name) as rowNum\r\n      FROM sometable\r\n) sub\r\nWHERE rowNum &gt; 20\r\n  AND rowNum &lt;= 30<\/pre>\n<p>In Oracle: <a href=\"https:\/\/www.withdata.com\/blog\/oracle\/how-to-limit-the-number-of-rows-returned-by-an-oracle-query-after-ordering.html\">https:\/\/www.withdata.com\/blog\/oracle\/how-to-limit-the-number-of-rows-returned-by-an-oracle-query-after-ordering.html<\/a> .<\/p>\n<p>In DB2:\u00a0<a href=\"https:\/\/www.withdata.com\/blog\/db2\/the-db2-equivalent-for-the-mysql-limit.html\">https:\/\/www.withdata.com\/blog\/db2\/the-db2-equivalent-for-the-mysql-limit.html<\/a>\u00a0.<\/p>\n<p>In Mysql: <a href=\"https:\/\/www.withdata.com\/blog\/mysql\/how-to-limit-the-number-of-rows-returned-by-an-mysql-query.html\">https:\/\/www.withdata.com\/blog\/mysql\/how-to-limit-the-number-of-rows-returned-by-an-mysql-query.html<\/a> .<\/p>\n<p>In Sqite: <a href=\"https:\/\/www.withdata.com\/blog\/sqlite\/how-to-limit-the-number-of-rows-returned-by-an-sqlite-query.html\">https:\/\/www.withdata.com\/blog\/sqlite\/how-to-limit-the-number-of-rows-returned-by-an-sqlite-query.html<\/a> .<\/p>\n<p>In PostgreSQL: <a href=\"https:\/\/www.withdata.com\/blog\/postgresql\/how-to-limit-the-number-of-rows-returned-by-an-postgresql-query.html\">https:\/\/www.withdata.com\/blog\/postgresql\/how-to-limit-the-number-of-rows-returned-by-an-postgresql-query.html<\/a> .<\/p>\n<p>You can visit this page for more information:\u00a0<a href=\"http:\/\/stackoverflow.com\/questions\/9261205\/the-sql-server-equivalent-for-the-mysql-limit\">http:\/\/stackoverflow.com\/questions\/9261205\/the-sql-server-equivalent-for-the-mysql-limit<\/a>\u00a0.<\/p>\n<p>Some SQL Server tools you can try: <a href=\"https:\/\/www.withdata.com\/sql-server\/\"> https:\/\/www.withdata.com\/sql-server\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In MySQL, you can use &#8220;Limit n,m&#8221;, like this: select * from sometable order by name limit 20,10 And in SQL Server, use this query: SELECT * FROM ( SELECT *, ROW_NUMBER() OVER (ORDER BY name) as rowNum FROM sometable ) sub WHERE rowNum &gt; 20 AND rowNum &lt;= 30 In Oracle: https:\/\/www.withdata.com\/blog\/oracle\/how-to-limit-the-number-of-rows-returned-by-an-oracle-query-after-ordering.html . In [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[289,1321],"class_list":["post-2093","post","type-post","status-publish","format-standard","hentry","category-sql-server","tag-equivalent-for-the-mysql-limit","tag-sql-server"],"_links":{"self":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/2093","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/comments?post=2093"}],"version-history":[{"count":13,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/2093\/revisions"}],"predecessor-version":[{"id":6432,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/2093\/revisions\/6432"}],"wp:attachment":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/media?parent=2093"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/categories?post=2093"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/tags?post=2093"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}