Solved

ASP sql server recordcount

Posted on 2010-11-11
5
518 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

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 …
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 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