Re: Best way to count records returned?
From: Dan Guzman (guzmanda_at_nospam-online.sbcglobal.net)
Date: 09/04/04
- Next message: Steve: "Can I select from one database / insert into another database?"
- Previous message: Dan Guzman: "Re: last"
- In reply to: Steve Lewis - Website Nation: "Best way to count records returned?"
- Next in thread: Steve Lewis - Website Nation: "Re: Best way to count records returned?"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 4 Sep 2004 10:07:26 -0500
IIRC, ADO returns OUTPUT parameters only after results are retrieved so you
need to first process the returned recordset. Also, include SET NOCOUNT ON
at the beginning of the proc to suppress DONE_IN_PROC messages that can
interfere with ADO resultset processing.
-- Hope this helps. Dan Guzman SQL Server MVP "Steve Lewis - Website Nation" <user@domain.com> wrote in message news:6MWdncMb2t6v5qTcRVn-vA@comcast.com... > What is the best way to count the number of records returned in a stored > proc.? > > I have tried using @@ROWCOUNT and assigning that to an Output parameter, > but that has not worked. I then researched and found others saying that I > should use count() because using @@RowCount is redundant. What is the best > way? > > I am using ASP, ADO and SQL Server 2000. I just want to display the number > of records returned. > > So far I have the following. It returns the records, but not the count: > > CREATE PROCEDURE prViewMemberImageUpload > @MemberID int, @RecordNum int OUTPUT > > AS > SELECT > ImageNew, ImageOriginalFilename > FROM > tblImage > WHERE > MemberID = @MemberID > > Set @RecordNum = @@Rowcount > Return @RecordNum > GO > > > > -- > ____________________________ > Steven K. Lewis > Website Nation, LLC > Website Development Services > www dot Website Nation dot com
- Next message: Steve: "Can I select from one database / insert into another database?"
- Previous message: Dan Guzman: "Re: last"
- In reply to: Steve Lewis - Website Nation: "Best way to count records returned?"
- Next in thread: Steve Lewis - Website Nation: "Re: Best way to count records returned?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|