You can do exactly that in SQL 2005. In SQL 2000 you had to do dirty hacks like using SET ROWCOUNT @val and then, after your select statement, set ROWCOUNT 0 to remove the rowcount restriction.
However, you have a slight syntax problem. You need brackets around @val, so it looks like
select top(@val) * from mytable