Information générale
Forum:
Microsoft SQL Server
Titre:
Updating a table with multiple field PK
Hello Group,
I am trying to update table conphone from table cisconphone that has raw data from several servers.
The Primary Key is composed of conuniq + phnnumber.
Several rows in the raw data have multiple conuniq + phnnumber combinations.
This problem is being addressed in the field.
This is my stab at the SQL Statement.
DELETE FROM conphone WHERE conuniq in (SELECT conuniq FROM cisconphone) and phnnumber in (SELECT phnnumber FROM cisconphone).
Will this accomplish my goal?
INSERT INTO conphone
SELECT * FROM cisconphone
WHERE conuniq not in (
SELECT conuniq
FROM cisconphone
GROUP BY conuniq
HAVING (COUNT(conuniq) > 1)
)
AND
phnnumber not in
(
SELECT phnnumber
FROM cisconphone
GROUP BY phnnumber
HAVING (COUNT(phnnumber) > 1)
)
Thanks
Jim
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement