|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
limit equivalent
Hi there
![]() I am searching for an equivalent to MySQL/PostgreSQLs "LIMIT" for MS SQL Server. Any ideas? |
|
#2
|
||||
|
||||
|
TOP as in:
SELECT TOP 50 fieldname1, fieldname2 FROM table Note that there's no equivalent in MS SQL for the two argument LIMIT clause, i.e. something like LIMIT 50, 10 to show 10 rows from the 50th row onwards. You cannot do this in MS SQL.
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by sizeablegrin, etienne141 and L7Sqr, superior C/C++ programmers of the month |
|
#3
|
||||
|
||||
|
Actually that second one was the one I was looking for, and I found kind of a work-around
I knew of the TOP, but for creating a page with a limited amount of entries the LIMIT 0,10 would be best - but this "kind of" works ![]() Code:
SELECT * FROM (
SELECT TOP x * FROM (
SELECT TOP x * FROM (
SELECT TOP (x+y) columns
FROM tablename
ORDER BY key ASC
) AS foo ORDER BY key DESC
) AS bar
) AS baz ORDER BY key ASC
I found it here, if somebody is interessted: http://216.239.39.104/search?q=cach...&hl=en&ie=UTF-8 |
|
#4
|
|||
|
|||
|
SELECT TOP
Can one use a variable when using SELECT TOP?
That is: SELECT top [ENTER NUMBER] DDAList_Main.IDNum, DDAList_Main.RAE_Assignment FROM DDAList_Main WHERE (((DDAList_Main.RAE_Assignment) Is Null)); rather than: SELECT top 10 DDAList_Main.IDNum, DDAList_Main.RAE_Assignment FROM DDAList_Main WHERE (((DDAList_Main.RAE_Assignment) Is Null)); |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > limit equivalent |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|