Find duplicate rows in MS SQL

by Syska 17. March 2010 17:51

So, the other day I was reading T-SQL: Why “It Depends” and in the comments section a guys suggested using the “PARTITION BY” in the OVER clause.

I thought was the heck does that do … so i searched the web for an answer … and wow … what a great way to find duplicate post … and possible also a lot of other things it can be used for that I haven’t thought about.

To the code …

WITH Data AS
(
	SELECT 
	ROW_NUMBER() OVER ( PARTITION BY CID ORDER BY Added DESC) AS DupeNumber
	,CID, Added
FROM Servers
)
SELECT * FROM Data Where DupeNumber >= 2

This will check for dupes on the CID column … and then select all the rows where DupeNumber is over or equal to 2. You could then instead of select it … you could delete it.

Fancy way … I like it.

Tags: , , ,

windows 7

Windows 7 & Excel, docking bug

by Syska 14. September 2009 11:34

So the other day I was using Excel for some work I needed to do. Maximized the window with the mouse, very nice feature in 7. Ups, wrong minotor I docked the window on. So I wanted to move it to the other monitor. But wait, I could not undock it when trying to undock it from maximized with the mouse. So clearly a bug ... wheater its in Wind ows 7 or Office that causes the window to not be undockable from maximized I dont know ... 

Its no problem when its docked to either left or right ... but, not impossible to undock from maximized with the mouse ... Embarassed

So if anyone know I can report this, please do tell.

Tags: , ,

windows 7

About the brain

Mikael SyskaMikael Syska

Student at the Engineering College of Aarhus.

Microsoft Student Partner ( MSP )

On this blog I will primarily write about .NET, MSSQL & projects I'm working on ... and of course there will some off topic posts :-)