Home Forums SQL Server 7,2000 T-SQL SELECT TOP X by using dynamic SQL RE: SELECT TOP X by using dynamic SQL
cliffb
SSCarpal Tunnel
Points: 4547
More actions
February 15, 2005 at 8:48 am
#542309
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'