Truncating duplicate entries in a table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • desirocks
    New Member
    • Sep 2007
    • 7

    Truncating duplicate entries in a table

    Hi,

    I have a table with no primary key and i just want to see all the duplicate entries on the basis of two columns. Can anyone suggest me how should i go about it.

    Can anyone provide me the syntax for the same?
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    As you have posted a question in the articles section it is being moved to SQL Server Forum.

    MODERATOR.

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      Originally posted by desirocks
      Hi,

      I have a table with no primary key and i just want to see all the duplicate entries on the basis of two columns. Can anyone suggest me how should i go about it.

      Can anyone provide me the syntax for the same?
      try:

      Code:
      select firstcolumn, secondcolumn, count(*) from myTable
      group by firstcolumn, secondcolumn
      will tell you how many duplicates are there per combination of those columns. you can either store the result to a temp table and join the original table to view the entire record or do a subquery

      Comment

      Working...