SELECT TOP
From: Elie Grouchko (egrouchko_at_hotmail.com)
Date: 01/23/05
- Next message: Joe K.: "NOLOCK statement"
- Previous message: Steve Kass: "RE: FLOAT datatype weirdness"
- Next in thread: Jacco Schalkwijk: "Re: SELECT TOP"
- Reply: Jacco Schalkwijk: "Re: SELECT TOP"
- Reply: David Gugick: "Re: SELECT TOP"
- Reply: Anith Sen: "Re: SELECT TOP"
- Reply: Pradeep Kutty: "Re: SELECT TOP"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 23 Jan 2005 17:48:59 +0200
Hi All
I am writing a stored procedure to retrieve the top n rows of a SELECT
statement.
I tried passing the number of rows as a variable (topcount in the example),
but I get a syntax error:
Am I missing something?
Thanks in advance
Elie Grouchko
CREATE PROCEDURE Proc_SelectTopForumCommentsOrderByDate
@topcount int,
@twc_comment_subject int
AS
SELECT TOP @topcount * FROM [twt_comment] WHERE
([twc_comment_subject] = @twc_comment_subject)
AND ([twc_comment_id] != @twc_comment_subject)
AND ([twc_comment_state] = 2) ORDER BY [twc_comment_date] DESC
- Next message: Joe K.: "NOLOCK statement"
- Previous message: Steve Kass: "RE: FLOAT datatype weirdness"
- Next in thread: Jacco Schalkwijk: "Re: SELECT TOP"
- Reply: Jacco Schalkwijk: "Re: SELECT TOP"
- Reply: David Gugick: "Re: SELECT TOP"
- Reply: Anith Sen: "Re: SELECT TOP"
- Reply: Pradeep Kutty: "Re: SELECT TOP"
- Messages sorted by: [ date ] [ thread ]