473,796 Members | 2,729 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deletion of Duplicate Row

Hi Everyone,

I have a table in which their is record which is exactly same.
I want to delete all the duplicate keeping ony 1 record in a table.
Example

Table A
Empid currentmonth Previousmonth
Supplimentaryda ys basic

158 2001-11-25 00:00:00.000 2001-10-01 00:00:00.000 2.00
4701.00
158 2001-11-25 00:00:00.000 2001-10-01 00:00:00.000 2.00
4701.00
158 2001-11-25 00:00:00.000 2001-10-01 00:00:00.000 2.00
4701.00
I want to delete 2 rows of above table.How can I achieve that.
Any suggestion how can i do that.
Thank you in advance
Richard

Jul 23 '05 #1
2 1533
Am 2 Jul 2005 00:10:03 -0700 schrieb Richard:
Hi Everyone,

I have a table in which their is record which is exactly same.
I want to delete all the duplicate keeping ony 1 record in a table.
Example

Table A
Empid currentmonth Previousmonth
Supplimentaryda ys basic

158 2001-11-25 00:00:00.000 2001-10-01 00:00:00.000 2.00
4701.00
158 2001-11-25 00:00:00.000 2001-10-01 00:00:00.000 2.00
4701.00
158 2001-11-25 00:00:00.000 2001-10-01 00:00:00.000 2.00
4701.00
I want to delete 2 rows of above table.How can I achieve that.
Any suggestion how can i do that.
Thank you in advance
Richard


there are some possibilities:
a) you can add a new column with type autoident, then you have no duplicate
rows and can delete them by hand or by script and afterwards you can remove
this column (but i think it is very bad table design having no primary key)
b) execute this script in the QueryAnalizer:
select distinct * into #tmp from myTable
delete myTable
insert into myTable select * from #tmp
(save your database before!!)

bye,
Helmut

Jul 23 '05 #2
hi Helmut,

a) you can add a new column with type autoident, then you have no
duplicate
rows and can delete them by hand or by script and afterwards you can remove
this column (but i think it is very bad table design having no primary key)
b) execute this script in the QueryAnalizer:
select distinct * into #tmp from myTable
delete myTable
insert into myTable select * from #tmp
Thank you, your both points works fine.

cheers :)
Richard

hwoess wrote: Am 2 Jul 2005 00:10:03 -0700 schrieb Richard:
Hi Everyone,

I have a table in which their is record which is exactly same.
I want to delete all the duplicate keeping ony 1 record in a table.
Example

Table A
Empid currentmonth Previousmonth
Supplimentaryda ys basic

158 2001-11-25 00:00:00.000 2001-10-01 00:00:00.000 2.00
4701.00
158 2001-11-25 00:00:00.000 2001-10-01 00:00:00.000 2.00
4701.00
158 2001-11-25 00:00:00.000 2001-10-01 00:00:00.000 2.00
4701.00
I want to delete 2 rows of above table.How can I achieve that.
Any suggestion how can i do that.
Thank you in advance
Richard


there are some possibilities:
a) you can add a new column with type autoident, then you have no duplicate
rows and can delete them by hand or by script and afterwards you can remove
this column (but i think it is very bad table design having no primary key)
b) execute this script in the QueryAnalizer:
select distinct * into #tmp from myTable
delete myTable
insert into myTable select * from #tmp
(save your database before!!)

bye,
Helmut


Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6593
by: Tuhin Kumar | last post by:
Hi, I have a requirement on improving the deletion rate on on records of a table. The table contains 5 million records, but since deleting everything matching the condition at one go was giving the ROLLBACK segment allocation error, the query was called in a loop and deleting 2000 rows at one interation. My query is: DELETE FROM Table1 WHERE TimeStamp >= TO_DATE('2003-11-30 18:30:00', 'YYYY-MM-DD HH24:MI:SS') and TimeStamp <=...
0
1771
by: Vic | last post by:
Hi all, When I test the Delete multi table function in MySQL, DELETE table_name ...] FROM table-references I accidentally delete all data in one table. All data in that table are gone when I try to select them out in Control Center. But when I go into the /mysql/data/mydatabase/, I see a MYD, MYI, frm for that table. And it seems that data is still inside the MYD, althought it's
6
1804
by: sumit | last post by:
i am trying to restrict deletion on local hard drives i have expertise in c, c++, and delphi if the solution can be found on any of the above languages plz inform me.
2
1652
by: Christopher Pisz | last post by:
currently my node is like so with everything public: class Quadtree_Node { public: Quadtree_Node(Quadtree_Node * parent, Bounding_Box & bounds); ~Quadtree_Node(); void Subdivide(float smallest_node); const Quadtree_Node *& GetTopLeft(); Bounding_Box m_bounds; // Bounding Coordinates of this node
1
1280
by: Dan | last post by:
Hi all, I have a question about datagrid: let's say I have a datagrid which shows the categories for some items; each category has an ID field and a description. I use an ASP.NET page with a datagrid bound to this table to show, edit or delete any row in this table. I have made a template of the edit/cancel column to be able to check for invalid values (e.g. an empty or duplicate category), using validators referring to the edit control of...
7
2024
by: TJS | last post by:
javascript "confirm" fires after deletion instead of before deletion. how do I get this to stop the processing ? code ================== Sub ShowAlert(ByVal s As string) RegisterClientScriptBlock("CSP-showconfirm-function", _ "<s"+"cript language=""JavaScript"">" & vbCrLf & _
2
1739
by: Rune Froysa | last post by:
I have one table with columns that are used as foreign-keys from several other tables. Sometimes deletion from this table takes +5 seconds for a single row. Are there any utilities that can be used to figure out why the deletion takes so long? "ANALYZE DELETE FROM foo WHERE bar=gazonk" doesn't really help as it only explains how the where statement is resolved, and not what postgres has to do to preserve database integrity. Regards,
3
1681
by: A_Republican | last post by:
I am interested in writing my own secure file deletion program. I want to be able to read and write to my hard drive directly. My application will seach my hard drive for all locations marked for deletion and then replace it with "x" or something that securely removes previoius data. My question is what objects, API calls, etc, etc do I use to read and write directly to the hard drive? -- Regards, Shaun Goldston
0
1373
by: ASMJ | last post by:
Hi, I have a gridview in my page, which displays all records from an sqldatasource. The delete row command is available to the user, through which he can perform deletion. I want to trap the gridview_RowDeleting event to display a confirmation msg to the user. Is there a msgbox kind of facility where I can get confirmation from the user before deletion?
0
9535
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10465
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10242
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9061
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5453
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4127
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.