How to do SELECT TOP @Param in a Stored Procedure?

Add parenthesis:

SELECT TOP (@NumberOfResultsToReturn) *

SQL Server: Put the argument in parens:

SELECT TOP (@NumberOfResultsToReturn) *

Here's how I was doing it in the old times:

SET @@ROWCOUNT = @NumberOfResultsToReturn
SELECT ........
SET @@ROWCOUNT = 0

This will work, although SELECT TOP (@NumberOfResultsToReturn) is preferable if you're using SQL server that supports this syntax: