MSSQL 2000 - Stored Procedure syntax problem

Stupendous

[H]ard|Gawd
Joined
Aug 29, 2000
Messages
1,370
Here is the sproc but there is a syntax error with "TOP @NumHeadlines". I'm not sure what is wrong. If I do "TOP 5" or something it works.

Code:
CREATE PROCEDURE dbo.News_RetrieveLatestHeadlines
@NumHeadlines int
AS
SELECT TOP @NumHeadlines ContentId,Title,PostDate
FROM Content WHERE Type='N'
ORDER BY PostDate DESC
GO

Thanks
 
u have to have a number after TOP. If you need the number to be a variable, you will have to concatenate strings and then execute that string.
 
Back
Top