troubleshooting Question

Removing duplicates

Avatar of hazemfadl
hazemfadlFlag for Egypt asked on
Microsoft SQL Server 2008
3 Comments1 Solution338 ViewsLast Modified:
Hello,

I have 2 tables:

District:
DistrictID      DistrictName
1                  Cairo
23                Cairo
44                Cairo
60                Alex
62                Alex
70                Aswan
74                Aswan
78                Aswan

Map:
MapID    DistrictID  MapName
1            1               ABC
2            44             XYZ
3            23             DEF
4            60             GHI
5            62             JKL
6            70             MNO
7            74             PQR
8            78             STU

As described above you will note that the MapID (1,2,3) has different ditrictID (and 4,5 and 6,7,8 have the same problem) though they are the same city, I need to do the following:

1- Update the "Maps" table to eliminate the duplicate districtid based on the duplication of the district table (I mean to make all the same district refer to a single DistrictID) -- the maps table have to be as follows:

MapID    DistrictID  MapName
1            1               ABC
2            1             XYZ
3            1             DEF
4            60             GHI
5            60             JKL
6            70             MNO
7            70             PQR
8            70             STU

2- Delete all the duplicates of the District table, districts table have to be as follows:
DistrictID      DistrictName
1                  Cairo
60                Alex
70                Aswan


Any ideas.

Thanks ...
ASKER CERTIFIED SOLUTION
twol

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros