Possible Duplicate:
Dynamic SELECT TOP @var In SQL Server
why am I getting a syntax error at select top @recNo
here?
create procedure getTopAccounts
(
@recNo int
)
as
begin
select top 1 accDesc, accNum
from
(select top @recNo accDesc,accNum
from
ACCOUNTS_TABLE
order by
accNum desc)
as a order by accNum
end