Hi I am using SQl Server 2008 and need to limit in my SQL query!
I was told to look at this code to get an idea:
;WITH Results_CTE AS
(
SELECT
Col1, Col2, ...,
ROW_NUMBER() OVER (ORDER BY SortCol1, SortCol2, ...) AS RowNum
FROM Table
WHERE <whatever>
)
SELECT *
FROM Results_CTE
WHERE RowNum >= @Offset
AND RowNum < @Offset + @Limit
I need to implement this into my current statement which wont work in SQL 2008.
$strSQL = 'SELECT * FROM BlogItem WHERE Blog_Live=1 LIMIT '.$rowsperpage.' OFFSET '.$offset.''; $objQuery = mssql_query($strSQL)
or die ("Error Query [".$strSQL."]");
Can anyone advise me on the way to do this? As looking at the first lot of code I am just lost!
Thanks