I want to create a stored procedure which takes integer values as a @top from me so that I can use it in my query, but it’s not allowing me to set value of top dynamically.
select top @top * from (select url,
count(1) as shared from tblshared
group by url, uniqid having
uniqid = @uniqid) as sha order by
shared desc
I want to retrieve top n records from table so I want to pass the value of n in stored procedure and it will return me that number of top records.
Note: I don’t want to use exec.
Thanks.
You could use SET ROWCOUNT: