Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mittalpa
Starting Member
2 Posts |
Posted - 2009-06-23 : 11:32:15
|
| Hi I want to select records 11 to 20 in sql server. In MySQL this is how it is done. How can we do it in SQL SERVER 2005 and above?SELECT * FROM employees LIMIT 10,10;In MySQL, LIMIT x,y means skip the first x records, and then return the next y records.ThanksPankaj |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-06-23 : 11:34:55
|
Use ROW_NUMBER() and choose rows >10 and < 21as inSELECT * FROM ( SELECT *, ROW_NUMBER() OVER (ORDER BY empid) as row FROM Employees) a WHERE row > 10 and row <= 20quote: Originally posted by mittalpa Hi I want to select records 11 to 20 in sql server. In MySQL this is how it is done. How can we do it in SQL SERVER 2005 and above?SELECT * FROM employees LIMIT 10,10;In MySQL, LIMIT x,y means skip the first x records, and then return the next y records.ThanksPankaj
|
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-06-24 : 00:03:46
|
| see this link it may helphttp://sqlblogcasts.com/blogs/madhivanan/archive/2008/09/12/return-top-n-rows.aspx |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|