Sai Stuff to Developers

June 23, 2010

Querry to Deleting Duplicate Records

Filed under: DataBase — tosaik @ 12:36 pm


  Many people will struct with their  work when comming to delete duplicate records in a table with single querry.
I want to make it easy your job by following Querry.

Note: this Querry works in Sql Server 7.0 and above versions
SELECT *,ROW_NUMBER() OVER(PARTITION BY <Fieldname>  ORDER BY <PrimaryKeyFieldName>) AS RANK1 FROM <TableName>
) Delete  FROM T WHERE RANK1 > 1


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at

%d bloggers like this: