• Greg,

    What's the best way of making your code dynamic? I tried declaring a variable so that the query became:

    declare @n int

    set @n = 76

    select top 1 salary from

    (select top @n employeeId from employee

    order by salary asc) a

    order by salary desc

    but SQL Server doesn't like it.

    I can get it to work with SET ROWCOUNT @n but I'm not sure what impact this has?

    Thanks

    Jeremy