﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Erik Andersen  / Handle Duplicate Records / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 18 May 2013 18:50:01 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Handle Duplicate Records</title><link>http://www.sqlservercentral.com/Forums/Topic626371-1442-1.aspx</link><description>No.  Sorry, the example is just pseudo-code, you'll have to replace some stuff to make it actually work.  I put the '...' there in case you wanted to add more variables than just @ID ("FETCH NEXT INTO @ID, @Whatever, @Something).  You could use the other variable in whatever processing you need to run, or if the primary key on that table is multiple columns you'd need to grab all of them just to delete.</description><pubDate>Tue, 07 Apr 2009 14:03:18 GMT</pubDate><dc:creator>erik-507089</dc:creator></item><item><title>RE: Handle Duplicate Records</title><link>http://www.sqlservercentral.com/Forums/Topic626371-1442-1.aspx</link><description>So the "..." after the "@ID" is not needed?I do understand the basics of variables, but am still learning how to use them properly.Thanks Ted</description><pubDate>Tue, 07 Apr 2009 13:39:19 GMT</pubDate><dc:creator>tlocke-512364</dc:creator></item><item><title>RE: Handle Duplicate Records</title><link>http://www.sqlservercentral.com/Forums/Topic626371-1442-1.aspx</link><description>No problem.  Anything with an @ in front is a variable.  @ID would hold a value for each row of the table that somehow uniquely identifies that row.  So, the cursor has you looping through all the duplicate values.  Each time it gets to "Fetch Next Into @ID", it puts the next value into the variable.Then, the first time through the loop, it assigns that to @KeepID.  And any subsequent loops, you would run all your logic to merge / move / delete the duplicate record.</description><pubDate>Tue, 07 Apr 2009 13:36:05 GMT</pubDate><dc:creator>erik-507089</dc:creator></item><item><title>RE: Handle Duplicate Records</title><link>http://www.sqlservercentral.com/Forums/Topic626371-1442-1.aspx</link><description>Sorry I am still a newbie when it comes to programming like this...What is the "@ID ..." signify.  I figured out the ListOfFields but just can't figure out what the "@ID..." signifies.  Thank YouTed</description><pubDate>Tue, 07 Apr 2009 10:57:06 GMT</pubDate><dc:creator>tlocke-512364</dc:creator></item><item><title>RE: Handle Duplicate Records</title><link>http://www.sqlservercentral.com/Forums/Topic626371-1442-1.aspx</link><description>I've found the easy way to remove duplicates is with the UNION statement:select * into aTempTablefrom SourceTableUNIONselect * from SourceTableGOtruncate table SourceTableinsert into SourceTableselect * from aTempTableGODoes this work for you?</description><pubDate>Wed, 07 Jan 2009 07:51:03 GMT</pubDate><dc:creator>jnichols-797753</dc:creator></item><item><title>Handle Duplicate Records</title><link>http://www.sqlservercentral.com/Forums/Topic626371-1442-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/scripts/duplicate+records/65381/"&gt;Handle Duplicate Records&lt;/A&gt;[/B]</description><pubDate>Sun, 28 Dec 2008 18:33:51 GMT</pubDate><dc:creator>erik-507089</dc:creator></item></channel></rss>