SQLTeam.com | Weblogs | Forums

Change PK from one column to other

I must delete PK in table#1 from column #2 (nvarchar(50) and set it to column #1 (uniqueidentifire) and after that set column #2 to UNIQUE. What happen whith the relations to other tables that use the old PK(column#2) in FK? Also what happen with the triggers in table#1?

What happen whith the relations to other tables that use the old PK(column#2) in FK?

That depends on the specific relationship. If there is a SQL FK pointing to the current PK, you won't be able to drop the PK constraint until you (temporarily) drop the FK(s). The easiest way is to script them out, drop them, alter the table, then re-create the FKs.

Also what happen with the triggers in table#1?

I'd expect the triggers to be ok. Since that column is stil unique, with a unique index, the trigger should be fine using that column to join on.