Hi,

How can I delete duplicate records from a table in a single query.
Thanks in advance.

Do you have any auto generated id? If not then add a autogenerated id into this table. Then select all records min id by creating a group & delete except them.

Hi,
Thank you for your replay. How can I write query for this.
Thanks in advance.

Post the table structure with few sample data.

I have a table 'tbl_Course'.

The table structure is:
1.Id int (set as primary key)
2. Coursename nvarchar(50)

The table contents are:
id Coursename
1 MBA
2 MBA
3 MCA
4 BCA

Here Coursename 'MBA' is repeated.
Then I want to delete duplicate values from the table.
I hope you can help me.

Thanks in advance.

DELETE FROM TBL_COURSE WHERE ID NOT IN(SELECT MIN(ID) FROM TBL_COURSE GROUP BY COURSENAME)

Hi,

How can I delete duplicate records from a table in a single query.
Thanks in advance.

by using DELETE word