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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 limit

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2011-07-09 : 14:30:49
how can i use the limit like in mysql
I would do

select * from customers limit 100,10

what's the equivalent in sql?

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-07-09 : 14:56:36
What is that supposed to do? What do you actually want from customers?

--
Gail Shaw
SQL Server MVP
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-07-09 : 16:19:33
There is no equivalent in SQL 2005 or SQL 2008 (but there will be an equivalent in Denali (the next version of SQL Server)). With 2005/2008, you can use row number function to get the same results. This link has examples - clearly not as simple (and probably not as efficient) as the LIMIT keyword.

If you don't need offset, you can use the TOP keyword to get the top N (or bottom N - use DESC in order by clause) rows for a given sort order.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-07-11 : 05:54:00
quote:
Originally posted by esthera

how can i use the limit like in mysql
I would do

select * from customers limit 100,10

what's the equivalent in sql?


Without order by clause limit will limit the resultsets with random order

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -