Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Updating a table with multiple field PK
Message
De
25/08/2002 18:17:27
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Updating a table with multiple field PK
Divers
Thread ID:
00693482
Message ID:
00693482
Vues:
58
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
Fil
Voir

Click here to load this message in the networking platform