hi,
i had more duplicate records in my table.
i want to keep one rest i want to delete. can you give me sql server 2000 query
6 3573
hi,
i had more duplicate records in my table.
i want to keep one rest i want to delete. can you give me sql server 2000 query
You could create a temporary table and insert all distinct records in there. Then truncate your original and repopulate with the contents of your temporary table.
You could create a temporary table and insert all distinct records in there. Then truncate your original and repopulate with the contents of your temporary table.
if it's a full duplicate record, meaning all columns of two or more rows are the same, try:
select * distinct into TempTable from YourTable
drop YourTable
select * intoYourTable from TempTable
you have to consider constraints, indices, triggers, etc
if it's a full duplicate record, meaning all columns of two or more rows are the same, try:
select * distinct into TempTable from YourTable
drop YourTable
select * intoYourTable from TempTable
you have to consider constraints, indices, triggers, etc
I'm guessing you mean TRUNCATE YourTable
hi suppose like following records
I had the table with 5 columns and many rows.
Now i want to delete the records which meets column1,column2,column3 are same
and keep one record in it.
Create Table T1 (Number int,name1 varchar(25), name2 varchar(25), name3 varchar(25), name4 varchar(25) )
Insert Into T1 values(1,'aaa','bbb','ccc','dd1')
Insert Into T1 values(1,'aaa','bbb','ccc','dd1')
Insert Into T1 values(1,'aaa1','bbb','qqq','ttt')
Insert Into T1 values(2,'www','xxx','yyy','zzz')
Insert Into T1 values(2,'www','xxx','nnn','mmm')
Insert Into T1 values(2,'www2','xxx','nnn','mmm')
Insert Into T1 values(3,'fff','ggg','hhh','iii')
Insert Into T1 values(3,'fff','ggg','rrr','lll')
Result shall be
1-aaa-bbb-ccc-dd1
1-aaa1-bbb-qqq-ttt
2-www-xxx-yyy-zzz
2-www2-xxx-nnn-mmm
3-fff-ggg-hhh-iii
hi suppose like following records
I had the table with 5 columns and many rows.
Now i want to delete the records which meets column1,column2,column3 are same
and keep one record in it.
Create Table T1 (Number int,name1 varchar(25), name2 varchar(25), name3 varchar(25), name4 varchar(25) )
Insert Into T1 values(1,'aaa','bbb','ccc','dd1')
Insert Into T1 values(1,'aaa','bbb','ccc','dd1')
Insert Into T1 values(1,'aaa1','bbb','qqq','ttt')
Insert Into T1 values(2,'www','xxx','yyy','zzz')
Insert Into T1 values(2,'www','xxx','nnn','mmm')
Insert Into T1 values(2,'www2','xxx','nnn','mmm')
Insert Into T1 values(3,'fff','ggg','hhh','iii')
Insert Into T1 values(3,'fff','ggg','rrr','lll')
Result shall be
1-aaa-bbb-ccc-dd1
1-aaa1-bbb-qqq-ttt
2-www-xxx-yyy-zzz
2-www2-xxx-nnn-mmm
3-fff-ggg-hhh-iii
You can implement this Using ROWCOUNT in Sql Server
You can implement this Using ROWCOUNT in Sql Server
http://www.sql-server-performance.com/dv_delete_duplicates.asp
use ROWCOUNT carefully.
specify 'SET NOCOUNT ON' to reset the count set by rowcount or else it may affect the normal operation
Sign in to post your reply or Sign up for a free account.
Similar topics
by: ms |
last post by:
Access 2000:
I am trying to delete duplicate records imported to a staging table leaving one
of the duplicates to be imported into the live table. A unique record is based
on a composite key of 3...
|
by: KT |
last post by:
Is there any one click solution that would do the trick? I would like
to create a button, so the person who maintains the database can
perform clean up work to delete duplicate records which...
|
by: rajeshkrsingh |
last post by:
Hi friends,
Step1-
create table duplicate
(
intId int, varName varchar(50)
)
insert into duplicate(intId,varName) values(1,'rajesh')
insert into duplicate(intId,varName) values(2,'raj12')...
|
by: AccessHunter |
last post by:
I am using the following code to find and delete records in a table. The logic will go through each record and if a duplicate row is found will delete it. I ran this code and it worked the first...
|
by: jmstur2 |
last post by:
I have a table with what I consider duplicate records. Data in all columns are duplicate except for the date column, meaning that duplicate data was entered on different dates and those dates were...
|
by: farouqdin |
last post by:
Hi all i have code which loops through table and deletes the duplicate
records. This code does it for one table. How do i change it so it
goes through several tables?
On Error Resume Next
Dim...
|
by: ramdil |
last post by:
Hi All
I have table and it have around 90000 records.Its primary key is autonumber field and it has also have date column and name, then some other columns
Now i have problem with the table,as my...
|
by: Dilip1983 |
last post by:
Hi All,
I want to delete duplicate records from a large table.
There is one index(INDEX_U1) on 4 columns(col1,col2,col3,col4) which is in unusable state.
First of all when i tried to rebuild...
|
by: watertraveller |
last post by:
Hi all. My ultimate goal is to return two columns, where no single value appears anywhere twice. This means that not only do I want to check that nothing from column A appears in column B and...
|
by: DontTell |
last post by:
Hi -
I am trying to delete duplicate records from a single table. The table has multilple records of duplicate purchase orders. In these instances I need to delete those records that have the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
|
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...
| |