Solved

ASP sql server recordcount

Posted on 2010-11-11
5
517 Views
Last Modified: 2012-08-14
I want to get the number of records in a recordset using a stored procedure.  The recordcount approach has been returning (-1) since i converted from dynamic sql in the web page to a stored procedure.  What is the best way to get the recordcount from the stored procedure?
0
Comment
Question by:Bob Schneider
5 Comments
 
LVL 32

Accepted Solution

by:
ewangoya earned 125 total points
ID: 34117831

This should work

CREATE PROCEDURE GetRecordCount
(
      @RecordCount bigint OUTPUT
)
AS
      SELECT
            @RecordCount = COUNT(*)
      FROM
            TABLENAME

or you can use a function as well
0
 
LVL 23

Assisted Solution

by:Rajkumar Gs
Rajkumar Gs earned 250 total points
ID: 34117854
You can @@rowcount to return the count of records.
Check the attached code

 
CREATE PROCEDURE YourStoredProcedure

(

      @RecordCount bigint OUTPUT

)

AS

begin

      SELECT *  FROM TABLENAME





     SET @RecordCount = @@rowcount 



end

go

Open in new window



Raj


0
 
LVL 23

Assisted Solution

by:Rajkumar Gs
Rajkumar Gs earned 250 total points
ID: 34117859
@@rowcount will return total number of records in the query that executed just before

Raj
0
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 125 total points
ID: 34117874
0
 

Author Closing Comment

by:Bob Schneider
ID: 34119218
Very helpful!
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now