Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting results of a Select Statement without returning results

Status
Not open for further replies.

egolds

MIS
Aug 29, 2001
105
US
Within a cursor I need to count rows in a table for a Customer ID and update or delete the data in a temp table depending on the count. I know I can use select and @@rowcount but this returns the results of the select statement (The final outcome will be a Crystal Report).

Is there any way of just counting what would be the rows of the select statement without returning the select set?

Thanks in advance
 
i assume you're doing this in a stored procedure?

if you select a count(*) aggregation into a variable, the result set doesn't get returned.

create procedure getCount
@count int OUTPUT

AS

SELECT @count = count(*)
FROM <yourtable>
WHERE <conditions>

GO


cheyney
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top