Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Updating a table with multiple field PK
Message
From
25/08/2002 18:17:27
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Updating a table with multiple field PK
Miscellaneous
Thread ID:
00693482
Message ID:
00693482
Views:
59
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
Map
View

Click here to load this message in the networking platform