Tuesday 6 January 2015

Removing Duplicates in a table

Rather unfortunate misapplication of OR in a WHERE clause led to a table containing duplicate entries. To remove them, I used the following: Delete x from ( select *, rn=row_number() over (partition by columnA order by columnB) from TABLE ) x where rn > 1;

Friday 19 December 2014

Hello!

Ok, new blog. Never had much luck keeping a blog active, but I've taken to doing a lot of work with SQL recently and got in the habit of saving little bits of it in .sql files on my desktop. That's getting unmanageable, so I thought I'd put them here instead (and if anyone knows a better way to do what I'm trying to do, great, let me know!)