Re: с MySQL на MS SQL
От: Alexey Rovdo Россия http://ru.linkedin.com/in/rovdo
Дата: 22.12.04 10:14
Оценка:
Здравствуйте, PVOID, Вы писали:

PVO>приходится мне для веб проектов переходиь с MySQL на MSSQL. И тут возник ряд вопросов.

PVO>Первый насущный: в MySQL есть такая опция селекта LIMIT, в которой говорится с какой строки, сколько строк мне нужно. В MSSQL я пока откопал только TOP, что в общем-то вообще не является заменой LIMIT. Не подскажете есть ли некое подобие, этой самйо LIMIT, а то даже не знаю где копать.


SELECT [ ALL | DISTINCT ]
[ TOP n [ PERCENT ] [ WITH TIES ] ]


--------------------
TOP n [PERCENT]

Specifies that only the first n rows are to be output from the query result set. n is an integer between 0 and 4294967295. If PERCENT is also specified, only the first n percent of the rows are output from the result set. When specified with PERCENT, n must be an integer between 0 and 100.

If the query includes an ORDER BY clause, the first n rows (or n percent of rows) ordered by the ORDER BY clause are output. If the query has no ORDER BY clause, the order of the rows is arbitrary.

WITH TIES

Specifies that additional rows be returned from the base result set with the same value in the ORDER BY columns appearing as the last of the TOP n (PERCENT) rows. TOP ...WITH TIES can only be specified if an ORDER BY clause is specified.


Т.е. можно использовать SELECT TOP n .... WITH TIES ORDER BY ...

Гляньте также описание переменной @@ROWCOUNT . Тоже может быть полезна для этих целей.
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.