Re: counting records in a recordset
From: Bob Barrows [MVP] (reb01501_at_NOyahoo.SPAMcom)
Date: 10/22/04
- Next message: Ray Costanzo [MVP]: "Re: counting records in a recordset"
- Previous message: mgm: "counting records in a recordset"
- In reply to: mgm: "counting records in a recordset"
- Next in thread: mgm: "Re: counting records in a recordset"
- Reply: mgm: "Re: counting records in a recordset"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 22 Oct 2004 14:33:32 -0400
mgm wrote:
> hello,
>
> I have a query that is supposed to return only 1 record, however I
> recently found that because of an error in the database it can return
> more than 1. So what I need to do is capture if it is more than 1
> record and alert the user to contact the database administrator. How
> can I get the count of records returned by a recordset? Is there no
> way besides looping through with a counter variable?
A better plan is to set up a unique index or primary key so that the
duplicates cannot occur. I cannot get into specifics because you did not
specify your database type and version, as well as the columns in your table
that are supposed to identify a unique record.
In the meantime, a grouping query will reveal the duplicate records:
select col1,col2
from tablename
group by col1,col2
having count(*) > 1
Bob Barrows
-- Microsoft MVP -- ASP/ASP.NET Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don't check it very often. You will get a quicker response by posting to the newsgroup.
- Next message: Ray Costanzo [MVP]: "Re: counting records in a recordset"
- Previous message: mgm: "counting records in a recordset"
- In reply to: mgm: "counting records in a recordset"
- Next in thread: mgm: "Re: counting records in a recordset"
- Reply: mgm: "Re: counting records in a recordset"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|