Unfortunately there is no way to edit the primary key inside of an existing data extension. ” After a Data Extension has been created, any established Primary Keys cannot be modified. ” (src). This instead would require you to create a new Data Extension with the required keys/settings.
Now this is all well and good for smaller DEs with only a few fields, but once you are recreating a DE with 50 or 60 fields, you start to rip out your hair and scream. Luckily there is a better way to do this.
My recommendation is to create a new DE using the ‘Create from Existing’ and then selecting your original DE as the ‘source de’.
This will prefill the field editing section with the fields/data types/etc. from your original DE.
You can then change your primary key(s) to fit your new request on this screen and then select ‘Create’. From there you just import in the data into this new DE and you are good to go.
Easiest way to do this is via a SQL query. Something like:
Select *
From [yourOriginalDE]
/* Target: yourNewDE */
/* Action: Overwrite */
You then run this query to move all the data over to the new DE. Please note that returned rows or values may need to be adjusted or output may be different depending on the changes to the primary keys.
I always forget there is a ‘crearte from existing’ instead ‘copy’ way.
Thanks for sharing!
Thank you! Works really well. You’ve saved me some heavy duty therapy money (or money for hair replacement)! : )