If you need to get top N rows by a variable that holds number of rows, this is how you can get it done in MS SQL 2005 or above:

Code:
declare @N int
set @N = 5

Select Top (@N) * from dbo.MyTable