title: How to delete duplicate rows in sybase, when you have no unique key?
body: <p>Yes, you can find similar questions numerous times, but:
  the most elegant solutions posted here, work for SQL Server, but not for Sybase (in my case Sybase Anywhere 11). I have even found some Sybase-related questions marked as duplicates for SQL Server questions, which doesn't help.</p>
  
  <p>One example for solutions I liked, but didn't work, is the <code>WITH ... DELETE ...</code> construct.</p>
  
  <p>I have found working solutions using cursors or while-loops, but I hope it is possible without loops.</p>
  
  <p>I hope for a nice, simple and fast query, just deleting all but one exact duplicate.</p>
  
  <p>Here a little framework for testing:</p>
  
  <pre><code>IF OBJECT_ID( 'tempdb..#TestTable' ) IS NOT NULL
    DROP TABLE #TestTable;
  
  CREATE TABLE #TestTable (Column1 varchar(1), Column2 int);
  
  INSERT INTO #TestTable VALUES ('A', 1);
  INSERT INTO #TestTable VALUES ('A', 1); -- duplicate
  INSERT INTO #TestTable VALUES ('A', 1); -- duplicate
  INSERT INTO #TestTable VALUES ('A', 2);
  INSERT INTO #TestTable VALUES ('B', 1);
  INSERT INTO #TestTable VALUES ('B', 2);
  INSERT INTO #TestTable VALUES ('B', 2); -- duplicate
  INSERT INTO #TestTable VALUES ('C', 1);
  INSERT INTO #TestTable VALUES ('C', 2);
  
  SELECT * FROM #TestTable ORDER BY Column1,Column2;
  
  DELETE &lt;your solution here&gt;
  
  SELECT * FROM #TestTable ORDER BY Column1,Column2;
  </code></pre>