• If you are concerned about NULLS for your variable, you can also do this:

     

    SET @sql = 'SELECT TOP ' + IsNull(str(@number),'100 PERCENT') + ' * FROM table_name'