Hi
I wish to select the top N percent from a table (into a temp table called #Results) where N is a variable passed to the Stored Proc.
Using the code as follows works fine
Select Top 5 Percent into #Results from MyTable
but if try
Declare @N as Int
Select @N = 5
Select Top @N Percent #Results from MyTable
I get and error
Is there any way I can use a variable to specify the % I wish to return
thanks
I wish to select the top N percent from a table (into a temp table called #Results) where N is a variable passed to the Stored Proc.
Using the code as follows works fine
Select Top 5 Percent into #Results from MyTable
but if try
Declare @N as Int
Select @N = 5
Select Top @N Percent #Results from MyTable
I get and error
Is there any way I can use a variable to specify the % I wish to return
thanks