Can i update data extension with auto generated random value

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?

Answers:

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.

Method 1

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).

Related documentation:


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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x