HI Folks ,
I have a problem with the primary keys in my main Db , I want to setup replication and looks like someone tampered with my database by removing the primary keys.and in order to setup replication i need this table to have primary keys .THere are duplicates in that table but they are nessecary...and for this reason the primary keys do not want to "stick" when i try and specify them.Can anybody help
BurnerWithout the PK, transactional replication won't work. You could use snapshot replication if you wanted.
If your table needs to have duplicate primary keys, you have a design problem. At some point, you'll probably need to fix it.
-PatP|||Hi pat ,
I know taht it wont work. What I want to know is ; is there a way to "restore" the primary keys ?What i did now was create another table with the exact same design ..specified my primary keys..but what i want to do now is import all my data into this table including my duplicates ..is there a way to do this ...using a script or something ..cause dts will not allow duplicates to be importing because of the primary key set on the table .|||I'm confused. I think that you wnat ALTER TABLE ADD CONSTRAINT if you want to put the PK constraint back on the table.
If you are trying to clean out the table, you can use:SELECT *
FROM icky_table AS a
WHERE 1 < (SELECT Count(*)
FROM icky_table AS b
WHERE b.PK = a.PK)This will show you the duplicate rows based on the PK values. You'll have to sort out which of those rows you want to keep and which you want to discard.
-PatP
No comments:
Post a Comment