July 26, 2005 at 7:12 pm
Does anyone have a script that can find duplicate entries in a table? Example:
Date Unit Company_Name
4/2/05 bu002 ABC Company
Duplicate entries that were made with the same information entered, but that will search the entire table with other duplicates for other dates, bu's and company names at the same time.
I do not to run one query at a time.
If someone could help I would greatly appreciate it. Thanks
July 26, 2005 at 8:26 pm
Hi do you want to eliminate the duplicates from the table (recommended) or just search for some values and show only one entry rather than duplicate entrys?
Mike
July 26, 2005 at 8:37 pm
At this point I do not want to eliminate anything, just find all duplicate entries.
July 26, 2005 at 8:42 pm
is this something where a "select distinct" won't do ?! there could be duplicates of any or all fields - or a combination thereof ?! could you provide some more sample data from your table ?!
hi mike
**ASCII stupid question, get a stupid ANSI !!!**
July 26, 2005 at 8:48 pm
Date Unit Company_Name
4/2/05 bu002 ABC Company
11/30/04 bu002 ABC Company
4/2/05 bu002 ABC Company
5/12/05 bu002 ABC Company
11/3004 bu002 ABC Company
Hope this helps!
July 26, 2005 at 8:51 pm
Hi sushila nice to see you. I joined a group hug the other day in the hopes you would show up which you never did so you owe me.
Mike
July 26, 2005 at 8:53 pm
and your result set should contain:
Date Unit Company_Name
4/2/05 bu002 ABC Company
11/30/04 bu002 ABC Company
5/12/05 bu002 ABC Company
is this correct ?!
**ASCII stupid question, get a stupid ANSI !!!**
July 26, 2005 at 8:58 pm
Yes.
July 26, 2005 at 9:02 pm
..in that case a "select distinct * from myTable" should give you what you're looking for!
yes - mike - i do owe you!
**ASCII stupid question, get a stupid ANSI !!!**
July 26, 2005 at 9:03 pm
if object_id('tempdb..Test') >0
DROP TABLE Test
CREATE TABLE Test
(
aTime datetime,
avalue varchar(10),
company varchar(20)
)
insert into Test values('4/2/05','bu002','ABC Company')
insert into Test values('11/30/04','bu002','ABC Company')
insert into Test values('4/2/05','bu002','ABC Company')
insert into Test values('5/12/05','bu002','ABC Company')
insert into Test values('11/3/05','bu002','ABC Company')
SELECT DISTINCT COMPANY
FROM Test
-- Returns ABC Company
HTH Mike
July 26, 2005 at 9:04 pm
Great but no Haggis
July 26, 2005 at 9:06 pm
no indeed - more like gaggis - yuck!
it HAS to be the blackbird pie....how quickly you forget!
**ASCII stupid question, get a stupid ANSI !!!**
July 26, 2005 at 9:06 pm
Thanks, I'll give it a try.
July 26, 2005 at 9:08 pm
ivelisse - let us know how it goes...don't mind us - we're "meeting" after a while hence catching up!
**ASCII stupid question, get a stupid ANSI !!!**
July 26, 2005 at 9:10 pm
MOI? Forget something you said. I will sing you a song of six pence
Mike
But I think you won the bet although there is still a week to go
Viewing 15 posts - 1 through 15 (of 42 total)
You must be logged in to reply to this topic. Login to reply