.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to delete duplicate entries from my table

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :

What I mean by duplicate is when

charField=charField and timestamp=timestamp for two or more records. 

So, how do I eliminate these records?

I would prefer to keep the one which has the lowest number in a third field (Score) if that is possible.

View Complete Post

More Related Resource Links

Delete Duplicate Records from MySQL table


I have Revision column in Quote table with time stamp (MySql table) now i am viewing the entire date and time my end user want to view only Date he doesnot want to see time how can i pull only date.i am displaying revision column in two ways one in grid view and another one in field value

Query in my Grid view
Dim query As String = "SELECT QuoteNumber,Revision,Vendor,PartNumber,status,Customer,Requestor from quotes"
On select check box in grid view, filed values will be loaded with data.

field value
txtRev.Text = dt.Rows(indx)("Revision").ToString()




Duplicate user entries in aspnet_Users table


 I'm using SqlMembershipProvider and SqlRoleProvider for user management.

Users are created by

Dim MCS As System.Web.Security.MembershipCreateStatus

Dim NewUser As MembershipUser = Membership.CreateUser(TB_UserName.Text, TB_Pw.Text, TB_Email.Text, TB_SecQuestion.Text, TB_SecAnswer.Text, False, MCS)

later, after email confirmation, I take the user into a specified role

Dim myUser As System.Web.Security.MembershipUser = Nothing

Delete Statement with nested select in where clause deletes all entries in a table


I have fallen into a trap unadvertedly causing all records in a table being deleted. Can anybody tell me, if this a the intended behaviour of SQL Server 2008 R2 or does anybody know a method how to safely discover those kinds of typos in advance?

Regards, Markus

Here follows a script reproducing the behaviour:









Can't perform Create, Update or Delete operations on 'Table(outbox)' because it has no primary ke



I'm a beginner in asp.net and I have some problem inserting data into sql server 2005 with linq.


my code is : 


        Dim Result As New SMS.SendResult
        If Result.status = 0 Then
            Label1.Text = "Your Message Sent Successfuly"
            Dim db As New IGSSDataContext
            Dim out As New outbox With {.ClientID = intRandomNumber, .From = User.Identity.Name, .TO = TextBox1.TabIndex, _
            .Time = Now, .Message = Message}
            out.ID = (ID)
            TextBox1.Text = ""

Delete Record From Table A that Is Not In Table B

I have two tables; Table A id, name 101, jones 102, smith 103, williams 104, johnson 105, brown 106, green 107, anderson   Table B id, name, city, state 101, jones, des moine, Idaho 103, williams, Corvallis, Oregon 104, johnson, Grand Forks, North Dakota 105, brown, Phoenix, Arizona 107, anderson, New York, New York   I need to delete records from Table A that are not in Table B.  My front end is writen in .net and I am using Data Access Layer along with a Business Logic Layer for data interaction.   I have tried at least seven variations of joining, right outer join, left outer join resulting in wiping our the entire table or nothing at all; not to mention deleting the record that ought to remain and keeping the record that needs to be deleted!   In my BLL I tried to capture the rowsAffected for the deletion by using-without success. Dim rowsAffected As Integer = Adapter.ID_Deletion(ID) If rowsAffected = 1 Then Exit Function Else Return rowsAffected = 1 End If   Please help.   MsMe.

SSRS Table hide duplicate by date

Hi, I am parikshit deshpande i am working in SSRS 2005 from last three months. I am trying to solve this problem please help me for that, I have one table as per  Date                     Shift                               Tons                       Passes 1/1/2009            Day                                    Formula                  Formula 1/1/2009           Swings                            1/2/2009           Day 1/2/2009     &nb

Duplicate records find in table

  Hi ALL, I want to find the dynamically check the primary key values and remove the duplicate records.. please suggest it.   Regards Ram

I have relation many to many - how can I delete records from intermediate table ?

I have tables: Books id title Authors id name BooksAuthors book_id author_id Entity Framework generated only models for tables Books and Authors in relation many to many. How can I delete from table BooksAuthors all records where book_id =5 ?

Duplicate rows in Table

Hi, I have a table with two rows Name  ||    Surname || Account No || Money Expensise || Amount                                                     Total ------------ Amount How can I display the last row Total at the bottom of the table not for every first row.  Thanks Anyone helps!

Delete objects from table using another table to select rows - help needed

I have one table named 'dbo.ac_Products'Within this table there is a column named 'ProductId'There is also another table named 'dbo.ac_CatalogNodes'Within this table there is a column named 'CatalogNodeId'and a column named 'CatalogNodeType'I need to delete all the rows from 'dbo.ac_Products' and 'dbo.ac_CatalogNodes' where 'ProductId' = 'CatalogNodeId' and 'CatalogNodeType' = 1Any help would be greatly appreciated!

Update duplicate field in same table

  hi I have a table with some other duplicate field as below   IssueID Title A1 Test1 A1 Test2 A2 Test3 A2 Test4 A3 Test5 A4 Test6   i want update all duplicate field based on IssueID and the final result will show as below   IssueID Title A1 Test1 A1 Test1 A2 Test3 A2 Test3 A3 Test5 A4 Test6 may someone help me?  

join - delete table(s)

I have two table:Parent has the key Id, UserIdChild has PaymentId, UserIdTo view the data using DropDownList.I want to delete information that is selected in the DropDownList (SelectedValue).My code:        products_to_delete var p = from and db.tbl_Payments                                 WHERE p.PaymentType.Contains (DropDownList1.SelectedValue)                                 Join in and db.tbl_PaymentDetails                                 He p.ID equals s.PaymentId                                 select p;        db.tbl_Payments.DeleteAllOnSubmit (products_to_delete);        db.SubmitChanges ();This code onl

Delete one table record if the no more record are associated from another table

Hello All,   In my scenario I have two tables say Table A and Table B. Table A has 3 records   Id Name Value 1 ABC 123 2 XYZ 456 3 PQR 789   Now in another table I have 4 records   Id FName Lname TableAID 101 ABC XYZ 1 102 AAA BBB 1 103 XXX YYY 1 104 PPP QQQ 2   Now I display table B records in gridview when I select 3 records say id 101,102,103 and click on delete button. Table B selected records should be deleted and its working fine.   The problem is that in Table A record 1 ABC 123 is only associated with that many records so when I delete that record from Table B at that time the associated record in Table A should also be deleted as no more association with that record in Table B.   So please give me query or appropriate solution for that.  

Prevent duplicate entry into aspnet_profile table through CreateUserWizard?


Is it possible to setup the CreateUserWizard to check for a duplicate entry in the aspnet_profile table (for a custom field) before the new user is created?  For example, if I added a phone number field and wanted to make sure nobody else could create an account using that same phone number if a user already has an account with that phone number in the aspnet_Profile table's PropertyValuesString row? 

Duplicate data table


Hi everyone,

I am having problems with my ASP.Net results.

When I pressed the view report button three times, it displays the table three time horrizontally.

The sql is a stored procedure that populates a pivot table.

How can make it display once every time I hitted the report.



InfoPath Forms : Adding rows dynamically from a SQL table along with a 'Delete' button per row


My requirement is something like this:

In a Task Approval form, I want to have a view which shows all the rows in a particular SQL table (in a infopath repeating table?). Along with each row, there should also be a button, on clicking which the row should disappear from the infopath view table. Do you think InfoPath can handle all this? :) 

To summarize:

1. How do I add rows to a table dynamically?

2. Per row, how do I create a button dynamically?

3. How do I remove the row from the view when the button is clicked?

Replicating a table to it's duplicate with different physical /index structure

Hello,  We're planning to replicate a very large table (about 1TB) -- Yes Table, not database.  Can afford only very little (10-20 min)  downtime.    Is it possible to have clean replication with the source table in the source database (non partitioned) to destination table in the destination database (partitioned and indexed differently than the source) ?   Although data is the same.     We're primarily doing this replication for paritioning sake , as we can't afford downtime.  So the plan is to replicate the entire source database to the destination.   There are 2-3 large tables that hold 80% of the database data.   So when both DBs are in sync, we'll repoint the production.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend