question

Ananth_Sql avatar image
Ananth_Sql asked

i have a table in that i have duplicate records.my requirement is i have to pass duplicate records into one table and distinct records into other table. entire requirement i have to solve in single Query.

Pls Folks Share Your Answers
duplicates
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
Usually, it's best to give your question a title, and then provide details in the question area. That way you can expand on details. The title is not the place to type the entire question. Also, when you get a helpful answer, mark that by clicking on the thumbs up next to the answer. When you get an answer that answers your question, mark that by clicking on the check mark next to that answer.
0 Likes 0 ·
Ananth_Sql avatar image Ananth_Sql commented ·
oh thanks Grant Fritchey for suggestions....
0 Likes 0 ·

1 Answer

·
KenJ avatar image
KenJ answered
How to identify duplicate rows has been addressed several times. Perhaps, if you review one of the previous answers, you'll be able to adapt it to your particular variation of the problem: [ http://ask.sqlservercentral.com/questions/48287/identify-and-remove-duplicates-help.html][1] [ http://ask.sqlservercentral.com/questions/41782/update-duplicate-records.html][2] [ http://ask.sqlservercentral.com/questions/89469/finding-and-returning-a-result-set-of-supplicate-r.html][3] [ http://ask.sqlservercentral.com/questions/3716/select-first-row-when-duplicate-rows-are-available.html][4] It is also helpful to define what constitutes a duplicate record - does the table have no primary key, so every single column is identical between the duplicate rows, or is there a primary key, but all of the non-primary key columns are identical between duplicate rows. Perhaps there are multiple portions of the same logical row which has had different columns duplicated across different rows due to an application error. "Single query" is another thing that can be difficult to pin down. Do you count using a CTE count as a single query? How about correlated subqueries within the context of a "single query" Union all? Can you only use the key word SELECT (or INSERT or UPDATE or DELETE) once? How about not at all: Executing a stored procedure is a "single query", though it can contain thousands of lines of SQL and tens or hundreds of queries. [1]: http://ask.sqlservercentral.com/questions/48287/identify-and-remove-duplicates-help.html [2]: http://ask.sqlservercentral.com/questions/41782/update-duplicate-records.html [3]: http://ask.sqlservercentral.com/questions/89469/finding-and-returning-a-result-set-of-supplicate-r.html [4]: http://ask.sqlservercentral.com/questions/3716/select-first-row-when-duplicate-rows-are-available.html
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.