Hi there, it seems the search feature refuses to work so i am posting a question which I am sure has been answered :)
What is the best way to get the LIMIT command functionality in SQL SERVER?
I am making an ASP.NET page, and am unsure how to go about tabbing through 100s of results.
Many thanks,
TazSql Server does not have a LIMIT functionality. You can either use TOP to only select the TOP n records, or implement your own paging.|||BTW: In .NET, you can implement paging through a .NET control. Performance isn't as good as building your own paging, but if you don't want to go through the trouble, it's worth looking into.|||Use SQL Server 2005? The LIMIT clause shouldn't be implimented in a relational database, even though it is quite convenient. In SQL 2005, Microsoft chose to implement this functionality due to user demand in spite of the fact that it limits the design of the database engine in other ways.
-PatP|||the SQL server equivalent of MySql LIMIT is TOP
MySQL
select * from MyTable LIMIT 10
SQL Server
select TOP 10 * from MyTable|||the SQL server equivalent of MySql LIMIT is TOPSo, where does the comma go?
While you are correct that the TOP predicate implements part of what LIMIT does in MySQL (i.e. the first parameter), it does not handle the paging portion (when there are two parameters). Paging result sets has no set based solution (because it is both stateful and sequence dependant), so it really should be implemented via an N-tier solution.
-PatP|||Right Pat. TOP is only a closest equivalent in Sql2K and having Limitations compared to MySql LIMIT.|||Please remember that both limit and top are dangerous if not paired with some order by's. Without that control, a relational DB is free to return records in any order it feels like.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment