General information
Forum:
Microsoft SQL Server
Title:
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
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only