I want to run an automation for adding random value into data extension field.
I have data extension with name RecordsDe which having 3 field FieldA, FieldB & PKey.
Now i want to add random number value to PKey that will be unique for each row.
Any solution for this?
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
The naming of your fields suggests that PKey should be your primary key, which cannot be empty in the first place, if you set up the data extension correctly.
So therefore you need to either
- add this functionality to the query that initially fills your data extension, or
- set it as a default value in the data extension setup.
For the SQL solution you could use the NEWID-function:
SELECT NEWID() as PKey, FieldA, FieldB FROM SourceDE
The data extension setup-version would be adding
GUID() as default value for that field.
However, both solutions lead to IDs that aren’t numerical, but rather IDs in GUID format (alphanumeric with dashes as separators).
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0