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 |
|
tehprince
Starting Member
9 Posts |
Posted - 2008-02-19 : 16:35:22
|
| Here is my SP:ALTER PROCEDURE [dbo].[spGetNews] @NewsItems int = 3AS SELECT TOP @NewsItems FeedTitle, FeedURL FROM NewsFeed ORDER BY FeedDate DESCI get an error however from the way I'm using @NewsItems in the select statement. Basically I need the ability to pass in the # of items to pull. So the default would beSELECT TOP 3 FeedTitle, FeedURLBut I would like to change the 3 to a parameter that could change.Any help would be most appreciated. |
|
|
tprupsis
Yak Posting Veteran
88 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-19 : 23:55:06
|
quote: Originally posted by tehprince Here is my SP:ALTER PROCEDURE [dbo].[spGetNews] @NewsItems int = 3AS SELECT TOP (@NewsItems) FeedTitle, FeedURL FROM NewsFeed ORDER BY FeedDate DESCI get an error however from the way I'm using @NewsItems in the select statement. Basically I need the ability to pass in the # of items to pull. So the default would beSELECT TOP 3 FeedTitle, FeedURLBut I would like to change the 3 to a parameter that could change.Any help would be most appreciated.
just put a braces around parameter |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-20 : 00:44:12
|
| Other method isSET ROWCOUNT @NewsItems SELECT FeedTitle, FeedURLFROM NewsFeedORDER BY FeedDate DESCSET ROWCOUNT 0MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|