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:
NEWID() as PKey,
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).