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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning only DUPLICATE Records

Status
Not open for further replies.

Rexolio

Technical User
Aug 29, 2001
230
Can anyone tell me a quick command for returning only DUPLICATE records from a SQL Database via ASP?

Sorry to keep hitting the board today...I've got several weeks of builtup questions that I haven't had a chance to post! :)
 
This would find duplicates in the name field.....

SELECT Name, COUNT(Name)
FROM MyTable
GROUP BY Name HAVING COUNT(Name) > 1
 
This didn't work for me. I kept get the following error message:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near ' '.
/admin/passwords/index.asp, line 12

on the following string:

SQL="SELECT Email, COUNT(Email) FROM tblAccounts GROUP BY Email HAVING COUNT(Email) > 1"
Set rsList = cnPerfect.Execute(SQL)

Line 12 is the last line above (Set rsList....)

Thanks,
Rexolio
 
Not sure, though i rarely use the execute...

normlly I do this:

-----------------------
Set rsList = Server.createobject("ADODB.Recordset")

rsList.open "String", MyConnection, 0, 1
----------------------

It will return two columns, the first being the email and the second being how many duplicates of that email.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top