Sai Stuff to Developers

June 23, 2010

Querry to Deleting Duplicate Records

Filed under: DataBase — tosaik @ 12:36 pm
Tags:

Hi,

  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
;WITH T
AS
(
SELECT *,ROW_NUMBER() OVER(PARTITION BY <Fieldname>  ORDER BY <PrimaryKeyFieldName>) AS RANK1 FROM <TableName>
) Delete  FROM T WHERE RANK1 > 1

Advertisements

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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: