Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
aggiekevin
Starting Member
14 Posts |
Posted - 2007-09-07 : 15:36:59
|
I'd like to be able to pass a parameter in to a stored procedure, with which I can specify the number of rows to return. So basically I want to do something likecreate procedure sp_GetSubset (@nRows int)asbegin set nocount on; select top @nRows * from myTableenddeclare @nRows intset @nRows = 20exec sp_GetSubset @nRowsUnfortunately this does not work. Can anyone suggest a way I can accomplish this? |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-09-07 : 15:55:19
|
You can use SET ROWCOUNT in SQL Server 2000. It accepts variables.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
aggiekevin
Starting Member
14 Posts |
Posted - 2007-09-07 : 17:43:49
|
quote: Originally posted by tkizer You can use SET ROWCOUNT in SQL Server 2000. It accepts variables.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/
Excellent! Worked like a charm. Thanks! |
 |
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2007-09-08 : 15:22:57
|
select top (@nrows),...from mytable--------------------keeping it simple... |
 |
|
|
|
|