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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Dynamically selecting Top# records in SP

Author  Topic 

sherpa99
Starting Member

20 Posts

Posted - 2005-07-22 : 09:28:57
I'd like to re-use a stored procedure that returns a given number of records based on the "quantity" passed into the procedure ... can this be done?


CREATE PROCEDURE articlesTop_get
(
@typeID int,
@languageCD char(2),
@regionCD char(2),
@quantity int
)

AS



SELECT Top @quantity
newsID,
headline,
intro,
story
FROM
articles

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-07-22 : 09:32:38
set rowcount @quantity

SELECT newsID,
headline,
intro,
story
FROM
articles

set rowcount 0


Go with the flow & have fun! Else fight the flow
Go to Top of Page

sherpa99
Starting Member

20 Posts

Posted - 2005-07-25 : 11:46:33
very elegant ... thanks!
Go to Top of Page
   

- Advertisement -