Thanks for the reply jemacc..
I've change the SQL to this:
Code:
SELECT TOP 1 *
FROM
(SELECT TOP 7 *
FROM myTable
ORDER BY id) AS TopOfTable
ORDER BY id DESC
but i want the number 'N' to be a variable, but this code wont work:
Code:
DECLARE @wanted int
SET @wanted = 7
SELECT TOP 1 *
FROM
(SELECT TOP @wanted *
FROM myTable
ORDER BY id) AS TopOfTable
ORDER BY id DESC
It says "
Incorrect syntax near '@wanted'". The number for TOP can't be a variable?